UI Testing Failure - Neither element nor any descendant has keyboard focus on secureTextField

后端 未结 24 1512
难免孤独
难免孤独 2020-12-12 10:41

This is my case:

let passwordSecureTextField = app.secureTextFields[\"password\"]
passwordSecureTextField.tap()
passwordSecureTextField.typeText(\"wrong_pass         


        
24条回答
  •  [愿得一人]
    2020-12-12 11:01

    Your first line is just a query definition, which doesn't mean that passwordSecureTextField would actually exist.

    Your second line will dynamically execute the query and try to (re)bind the query to UI element. You should put a breakpoint on it and verify that one and only one element is found. Or just use an assert:

    XCTAssertFalse(passwordSecureTextField.exists);
    

    Otherwise it looks ok, tap should force keyboard visible and then typeText should just work. Error log should tell you more info.

提交回复
热议问题