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

问题描述 投票:3回答:1

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

我认为这对于默认的XCUIElementXCUIElementAttributes(对于它们的实际含义来说仍然有些模糊)是不可行的,而且我并不真正理解我应该如何以及如何扩展为了能够对此进行测试。

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

ios xcode swift uikeyboard ui-testing
1个回答
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);

我希望这对您有用。

© www.soinside.com 2019 - 2024. All rights reserved.