//Helper
class UITest: XCTestCase {
final func setInitalCredentials() {
print("\(app.textFields.count)") <-- prints (1)
let loginTextField = app.textFields["LoginTextField"] <-- is found
loginTextField.tap()
let deleteKey = app.keys["delete"]
let _ = deleteKey.waitForExistence(timeout: 2)
deleteKey.press(forDuration: 2)
loginTextField.typeText("login")
let passwordTextField = app.textFields["PasswordTextField"] <- is not
passwordTextField.tap()
let _ = deleteKey.waitForExistence(timeout: 2)
deleteKey.press(forDuration: 2)
passwordTextField.typeText("password")
}
var app: XCUIApplication!
override func setUp() {
super.setUp()
continueAfterFailure = false
app = XCUIApplication()
app.launch()
app.launchArguments.append("--uitesting")
}
override func tearDown() {
app.terminate()
super.tearDown()
app.launch()
}
}
//Actual test
class UILoginViewTest: UITest {
func testLogin() {
setInitalCredentials()
let loginButton = app.buttons["Connect"]
loginButton.tap()
let applicationRootView = app.otherElements["QuotesViewController"]
let _ = applicationRootView.waitForExistence(timeout: 10)
XCTAssert(applicationRootView.exists)
}
}
我错过了什么?为什么找不到第二个UITextField
?我确定所有ID都已设置,我甚至无法通过占位符或文字访问它,因为XCUIElementQuery
告诉我只有1 UITextField
。
答案 0 :(得分:0)
app
有secureTextFields
,其中包含任何`UITextFields&#39;安全文本输入。