XCode 7中的UITest:如何测试键盘布局(keyboardType)

时间:2015-10-16 22:34:05

标签: ios xcode swift uikeyboard ui-testing

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

对于默认的XCUIElementXCUIElementAttributes(我对它们的实际意义仍然有点模糊)我不认为这是可行的,我真的不明白怎样和什么我应该扩展以便能够测试它。

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

于连

1 个答案:

答案 0 :(得分:0)

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

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);

我希望这对你有用。