复选框在iPad上无法打到 - XCUITest Apple

时间:2018-06-15 07:55:13

标签: ios swift ipad fastlane xcuitest

我正在为Fastlane截图自动化的XCUITest工作。以下所有代码在每个iPhone模拟器上都能正常运行。这只是iPad的一个问题。

启动应用程序后,我处理权限,然后打开一个TermsOfUse对话框:

enter image description here

每当我到达检查复选框的步骤(之后是“接受”按钮)时,UITest崩溃并出现以下错误:

Not hittable: Switch, 0x600000397010, traits: 9007345283760129, label: 'termsOfUseAcceptedCheckbox', value: 0

这是处理程序的代码:

func handleTermsOfUse() {
        RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: NSDate(timeIntervalSinceNow: 10) as Date)

    let termsOfUseAcceptedCheckbox = app.switches["termsOfUseAcceptedCheckbox"]
    self.waitForElementToAppear(element: termsOfUseAcceptedCheckbox, timeout: 40)
    if(termsOfUseAcceptedCheckbox.exists) {
        termsOfUseAcceptedCheckbox.isAccessibilityElement = true
        termsOfUseAcceptedCheckbox.tap()
    }


    let termsOfUseAcceptedButton = app.buttons["termsOfUseAcceptedButton"]
    self.waitForElementToAppear(element: termsOfUseAcceptedButton, timeout: 40)
    if(termsOfUseAcceptedButton.exists) {
        termsOfUseAcceptedButton.isAccessibilityElement = true
        termsOfUseAcceptedButton.tap()
    }
}

这是调用方法的部分:

 override func testApp() {
        super.testApp()

        snapshot("01splashScreen")
        //self.handlePermission()
        self.handleTermsOfUse()
        sleep(5)
        snapshot("02index")
}

我不知道为什么会在 iPad 上发生这种情况,并且可以在iPhone上正常使用。 我用forceTap()方法尝试了它,但没有成功。

func forceTapElement() {
        if self.isHittable {
            self.tap()
        }
        else {
            let coordinate: XCUICoordinate = self.coordinate(withNormalizedOffset: CGVector(dx: 0.0, dy: 0.0))
            coordinate.tap()
        }

我希望有人知道如何让它在iPad模拟器上运行。

0 个答案:

没有答案