【问题标题】:UITest in Xcode 7: How to test keyboard layout (keyboardType)Xcode 7 中的 UITest:如何测试键盘布局(keyboardType)
【发布时间】:2015-10-16 22:34:04
【问题描述】:

我目前正在探索 Xcode 中的新 UITest 库,我想测试在 UITextView 内单击时弹出的键盘是否具有正确的类型(在这种情况下应该是 .PhonePad)。

我认为这对于默认的 XCUIElementXCUIElementAttributes 是不可行的(它们的实际含义对我来说仍然有点模糊),我真的不明白我应该如何以及应该做什么扩展以便能够对此进行测试。

任何帮助将不胜感激! :)

【问题讨论】:

    标签: ios xcode swift uikeyboard ui-testing


    【解决方案1】:

    下面的代码我用于测试电话号码和密码验证检查。

    let app = XCUIApplication()
    let tablesQuery = app.tables
    tablesQuery.cells.containingType(.StaticText, identifier:"Login Using").buttons["Icon mail"].tap()
    tablesQuery.textFields["Phone Number"].tap()
    tablesQuery.cells.containingType(.SecureTextField, identifier:"Password").childrenMatchingType(.TextField).element.typeText("ooo")
    tablesQuery.staticTexts["Login Using"].swipeUp()
    tablesQuery.secureTextFields["Password"].tap()
    tablesQuery.cells.containingType(.Button, identifier:"Login").childrenMatchingType(.SecureTextField).element.typeText("eeee")
    tablesQuery.buttons["Login"].tap()
    app.alerts["Error"].collectionViews.buttons["OK"].pressForDuration(1.1);
    

    我希望这对你有用。

    【讨论】:

      猜你喜欢
      • 2016-01-19
      • 2018-01-02
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 2016-03-10
      • 2015-10-02
      相关资源
      最近更新 更多