Appium 1.2.2: Unable to unlock the screen in HTC one

Appium 1.2.2
java 1.6.2
Win 7
HTC one device

Steps to reproduce:

  1. Initialize the driver with settings app.

  2. Device has password set.

  3. Lock the screen through the Application under test.

  4. find text element

                   List<WebElement> textfields = driver.findElementsByClassName("android.widget.EditText");
     		for (int i = 0; i < textfields.size(); i++){
     			WebElement input = textfields.get(i);

But text fields returning empty. If i manually enter some key then the password text is shown and the above code works.
How to enter the password?

FYI, i am sharing the HTC screens:
HTCONE_ScreenLock_Page_not_showing_textbox.png (The screen do NOT show the text box until we click some number in keyboard)
HTCONE_ScreenLock_passwordentry.png (if this screen appears the above code works, but how to come to this screen?).


Hmm. Pretty sure the textfield you are finding isn’t the one you are actually entering numbers into.

We use a special android unlock.apk app to unlock the screen. Maybe take a look at how that project works?

If you set the lock method to not use a password, you can use the lock command.

1 Like

Thanks Jonahss for the reply. The send info is not happening since it is not finding the text field unless some number is typed on it. (Please see the snapshots attached in above discussion).

I tried with unlock_apk command, i see this screen HTCONE_ScreenLock_Page_not_showing_textbox.png only .
The device is not getting unlocked.

C:\Users\ganma05>adb shell am start -n io.appium.unlock/.Unlock
Starting: Intent { cmp=io.appium.unlock/.Unlock }

C:\Users\ganma05>adb shell am start -n io.appium.unlock/.Unlock
Starting: Intent { cmp=io.appium.unlock/.Unlock }


This kind of issue i am seening even in Sansung Note 2.

Can you please help in resolving this issue ASAP?

Hmm, not sure how to help you. Maybe @jlipps or @isaac can weigh-in?

I don’t know of any way to automate the pin screen. Can you just turn off the lock code on the device so that screen never shows up?

in my usecase the password has to be already set.
We need to find a way how to unlock the screen (How to enter the password if the screen is locked).


From a ‘just looking at the problem and not having done it myself’ perspective - I’d try a series of specific ‘blind’ touches that happen to correspond to the positions of the number sequence. (and then hit enter, of course)

This would actually emulate what the user would do - as opposed to loading a series of numeric values through ‘the side door’ as it were. From a QA perspective that might be a more authoritative strategy, even if it’s more difficult to read in the code (and may be brittle - if the code is changed the test will break).

Anyway - food for thought.

Is there any way to send adb shell keyevent to the device from Appium? And put the pin as part of the keyevent?

The main problem is using secure network by key where you couldn’t use mobile without pin/pass code. For Nexus4 I got the unlock app working, but for Note3 - nope:-(
Of course, I did workaround by adb…But got it in the box of unlock.apk will be much better