Created
May 20, 2019 20:15
-
-
Save FabiolaRamirez/99466953d48b35a9e442851478cafedd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension XCUIElement { | |
| func scrollToElement(element: XCUIElement) | |
| { | |
| while element.visible() == false | |
| { | |
| let app = XCUIApplication() | |
| let startCoord = app.tables.element.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)) | |
| let endCoord = startCoord.withOffset(CGVector(dx: 0.0, dy: -262)); | |
| startCoord.press(forDuration: 0.01, thenDragTo: endCoord) | |
| } | |
| } | |
| func visible() -> Bool | |
| { | |
| guard self.exists && self.isHittable else | |
| { | |
| return false | |
| } | |
| return XCUIApplication().windows.element(boundBy: 0).frame.contains(self.frame) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment