Skip to content

Instantly share code, notes, and snippets.

@FabiolaRamirez
Created May 20, 2019 20:15
Show Gist options
  • Select an option

  • Save FabiolaRamirez/99466953d48b35a9e442851478cafedd to your computer and use it in GitHub Desktop.

Select an option

Save FabiolaRamirez/99466953d48b35a9e442851478cafedd to your computer and use it in GitHub Desktop.
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