【问题标题】:UITest. How to check if keyboard exists?用户界面测试。如何检查键盘是否存在?
【发布时间】:2015-08-25 14:23:49
【问题描述】:

XCTAssertTrue(app.keyboards.elementBoundByIndex(0).exists) 导致崩溃。那该怎么做呢?是否可以检查keaboard是否存在?

【问题讨论】:

    标签: ios swift xcode ios9 xcode-ui-testing


    【解决方案1】:

    XCTAssertEqual(app.keyboards.count, 1) - 键盘存在。 XCTAssertEqual(app.keyboards.count, 0) - 键盘不存在。

    【讨论】:

    • 如果键盘存在,有没有办法可以关闭它?
    【解决方案2】:

    另一种方法是检查textField是否包含Keyboard Focused

    let emailTextField = app.textFields.element(boundBy: 0)
    XCTAssertTrue(emailTextField.debugDescription.contains("Keyboard Focused")))
    

    【讨论】:

      猜你喜欢
      • 2012-12-31
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      • 1970-01-01
      • 2022-12-05
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多