0
嘗試創建一個UITest,用於在文本字段中輸入電子郵件地址/密碼,然後點擊登錄按鈕。使用Xcode。Swift UITest - 未找到與可訪問標識符的textField匹配
我看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")
}
可訪問性指標分別是「email」和「password」。當我自己運行模擬器時,登錄工作正常。
編輯:顯然有根本沒有文本字段(計數= 0),即使我看到他們,並利用它們在頁面上...
Image of storyboard with text fields