Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Testing iOS, Selecting Secure Text Entry textField

I have password and password conf textFields that I have applied the "Secure Text Entry", to mask the password. However, when I run the UI tests, those fields can not be found getting

UI Testing Failure - No matches found for "password" TextField

I'm attempting to select the fields like so:

let passwordTextField = app.textFields["password"]

but then it fails when I try to tap:

passwordTextField.tap()

Any ideas on how I can access the field?

like image 922
sebradloff Avatar asked Oct 23 '15 16:10

sebradloff


2 Answers

As discussed in the comments, when accessing a secure text field use the secureTextFields selector.

let passwordTextField = app.secureTextFields["password"]
passwordTextField.tap()
passwordTextField.typeText("my secure password")
like image 120
Joe Masilotti Avatar answered Oct 13 '22 00:10

Joe Masilotti


Also if you need to type to secureTextField

If menu I/O Hardware Keyboard is ON typeText not working for secureTextField.

enter image description here

Use below to type to secure field

        password.tap()

        app.keys["t"].tap()
        app.keys["e"].tap()
        app.keys["s"].tap()
        app.keys["t"].tap()
like image 44
zdravko zdravkin Avatar answered Oct 13 '22 01:10

zdravko zdravkin