So with the new xcode update apple has revamped the way we do UI testing. In instruments we used java script function \"isVisible\" to determine if our targeted element is visib
Unfortunately .exists
doesn't confirm that an element is currently visible - something like this still isn't perfect but it will provide more reliable validation working with table or collection view cells:
extension XCUIElement {
var displayed: Bool {
guard self.exists && !CGRectIsEmpty(frame) else { return false }
return CGRectContainsRect(XCUIApplication().windows.elementBoundByIndex(0).frame, frame)
}
}
then you can write a simple loop like:
func scrollDownUntilVisible(element: XCUIElement) {
while !element.displayed {
swipeDown()
}
}