How to fill in password EditText with Android uiautomator?

kevin.schultz picture kevin.schultz · Feb 19, 2013 · Viewed 8.8k times · Source

Is it possible for the uiautomator to select a password EditText? I have no problem finding other EditText views by their android:hint property, but the uiautomatorviewer shows all password fields as NAF. I tried setting the password field content description and that didn't work either.

If it's not possible, how do you set a timeout for a tester to manually enter a password?

Answer

Michal Vician picture Michal Vician · Mar 31, 2013

I had the same problem with API v16. Today I tried my script with v17 (Android 4.2) and it worked like a charm. It seems that the first version of uiautomator has some major bugs.

Here is my code:

// click the admin button
new UiObject(new UiSelector().text("admin")).click();
// set pwd text
new UiObject(new UiSelector().description("pwdEditText")).setText("admin");
// click login button
new UiObject(new UiSelector().description("loginButton")).click();