pru*_*tte 2 xcode textfield swift uitest
尝试创建UITest,以在文本字段中输入电子邮件地址/密码,然后单击登录按钮。使用Xcode。
我看到UITest导航到正确的页面,但是没有检测到文本字段。我确保两个文本字段都选中了“可访问性”框,并且已经为其指定了标识符。
我收到此错误:
UI测试失败-找不到与文本字段匹配的项
func testExample() {
let app = XCUIApplication()
//Test login page
app.buttons["loginButton"].tap()
//Here it navigates to the desired page
let emailField = app.textFields["email"]
emailField.tap()
emailField.typeText("xxx.xx.edu")
let passwordField = app.textFields["password"]
passwordField.tap()
passwordField.typeText("xxx")
app.buttons["loginButton"].tap()
// let loginAlert = app.alerts["alertVC"]
// XCTAssertEqual(loginAlert.title, "Error")
}
Run Code Online (Sandbox Code Playgroud)
可访问性指示器分别是“电子邮件”和“密码”。我自己运行模拟器时,登录工作正常。
编辑:显然根本没有文本字段(计数= 0),即使我看到它们并在页面上使用它们...
具有文本字段的情节提要的图像:

小智 7
如果UITextFiled设置为SecureTextEntry true,则应使用:
let passwordField = app.secureTextFields["password"]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1434 次 |
| 最近记录: |