Is it possible to open the lock by using appium in android?

Is it possible to open the lock by using appium in android?
I have used driver.lockScreen(int some seconds); for locking the screen.and again I need to open the lock go to the screen…Can it will be possible with Appium in Android device…

Try to execute adb shell input keyevent 26 twice


Ya kirill…its working fine for locking the screen .But i want to open the lock screen and go to the Home screen.Could you pls tell me whether it is possible with the Appium Script or through command… Thank you in advance…!!!

If your device is locked, Appium will try to unlock the device using unlock_apk-debug.apk.
This apk should be installed already on your device by appium server. It’s done automatically.
All you need to do is to start activity:

adb shell am start -n io.appium.unlock/.Unlock

apk is located in appium/build/unlock_apk/unlock_apk-debug.apk if you run from source code


1 Like

It’s working fine kirill…Thank you so much.!!!

But is there any possibility to get unlocked through the appium Script. …?
For locking-- driver.lockScreen(int seconds); is there.
For Unlocking–???

Thanks for the reply and in advance too… :smile:

As I said above:

adb shell am start -n io.appium.unlock/.Unlock
1 Like

Ya…Thank you @kirill :smile:

1 Like

You are welcome! Hope that helped :wink:

1 Like

Hi Kirill/Bhaskar,

I am new to appium, so this basic question.

How you are executing these commands from scripts/test cases?

We generally know we set some desiredcapabilities to driver, and then say driver.lockScreen locks the screen.

But how can i use the above command in my script. Can you please elaborate?

Thanks in advance,

Depends what language you use.
Google “execute shell command on Java/Ruby/Python/etc”

Yes, @UD Uday !!!
You can unlock the screen , place this statement in your code :
Runtime.getRuntime().exec(adb shell am start -n io.appium.unlock/.Unlock);
By the way i’m using Java…you can go with your desired language, the explanation about this command clearly mentioned above by Kirill…

Is there something equal for iOS devices as well ?

@kirill - from some reason , the command doesn’t work for me on one of our env
Running GenyMotion device , I’m executing the command , and the application doesn’t return from background.

All I see it’s a black screen with “unlock” title

Any idea what has been broken here ?

it does , work from me on other env…

both env are running the same configuration


I have exactly the same problem. Running in real device - Moto G, all software updated.

Hey there…

Appium now provides the functinality by which you can unlock any kinds of lock using the capabilities.

In latest version of Appium (1.6.4), you need to set 2 capabilities which are as follows:

“unlockType”: “pin”,
“unlockKey”: “1111”

unlockType: [‘pin’, ‘password’, ‘pattern’, ‘fingerprint’]

Refer the attached Readme file here.


1 Like

That’s a great thing even if pattern is also handled by Appium.

Hi Mashkur,
I tried the above capabilities but in order to attempt for the patter, I need to swipe up in the lock screen. Can you let us know about how to do the same?

I think for swiping up the android, you may need to go by screen size (I am not sure whether this capability is inbuilt in the appium, have you tried it?)… Following is the code for swipe up… Try and let me know if it doesn’t work.

Runtime.getRuntime().exec(“adb shell input swipe 257 1235 572 1235”);

The digits are for x and y co-ordinates, you need to adjust them based on your mobile resolutions.

It doesn’t work :frowning:

Paste your code and Appium logs here for more debugging. Also let me know the device that you are using for testing