Scroll until element is visible iOS UI Automation with xcode7

后端 未结 9 970
小鲜肉
小鲜肉 2021-01-30 10:39

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

9条回答
  •  感动是毒
    2021-01-30 11:12

    Expanding on @Kade's answer, in my case, had to account for tabbar in scrollToElement, else might get a tabbar button tapped if the view was under the tabbar:

    func scrollToElement(element: XCUIElement) {
        while !element.visible() {
            swipeUp()
        }
        // Account for tabBar
        let tabBar = XCUIApplication().tabBars.element(boundBy: 0)
        if (tabBar.visible()) {
            while element.frame.intersects(tabBar.frame) {
                swipeUp()
            }
        }
    }
    

提交回复
热议问题