Access ID does not work when testing a textfield with `isSecureTextEntry = true`

落花浮王杯 提交于 2019-12-11 00:43:53

问题


So i am trying to access and confirm the presence of a password textfield in my uitests but as soon as assign their isSecureTextEntry = true the tests can no longer find them by the accessID. Does any one know why? and if there is a way around this so that i can find them and use them in the tests? Preferably so that i can still use the access ID to locate them in the tests.

My test is very simple:

func testHasPasswordTextField() {
    let passwordTextField = app.textFields[AccesID.passwordTextField]

    XCTAssertTrue(passwordTextField.isHittable)
}

I get the following error when running the test:

"No matches found for Find: Elements matching predicate '"Password" IN identifiers' from input {( TextField, 0x600000193e80, traits: 146029150208, identifier: 'Email', placeholderValue: 'Email' )}".

the test passes happily if isSecureTextEntry = false(or just not set)


回答1:


Ok, so a colleague just found out for me that when testing and finding a textfield by its accessabilityidentifier and isSecureTextEntry is set to true the textfield is now found in tests as secureTextFields so my test passes as before but now looks like this:

func testHasPasswordTextField() {
    let passwordTextField = app.secureTextFields[AccesID.passwordTextField]

    XCTAssertTrue(passwordTextField.isHittable)
}


来源:https://stackoverflow.com/questions/45551667/access-id-does-not-work-when-testing-a-textfield-with-issecuretextentry-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!