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

我认为使用默认的XCUIElementXCUIElementAttributes(对于它们的实际含义仍然有些模糊)是不可行的,而且我并不太了解如何扩展我的内容以及为了扩展测试一下。

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

最佳答案

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

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

希望对您有用。

关于ios - Xcode 7中的UITest:如何测试键盘布局(keyboardType),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33180538/

10-12 04:25