问题
I have a task that I need to write Android mobile test automation using Appium and selenium in Java.I have to do scenario that phone has to be unlock using PINCODE pro-grammatical way.
Is there anyway to unlock android mobile in automation tests using pincode? Can anyone give me any suggestions to do this task.
回答1:
There is no capability in Appium to unlock the pattern/pin lock though appium can wake our device up. To lock/Unlock the screen we need to use ADB commands, below are few examples you can give a try to:
To wake the device from sleep mode
adb shell input keyevent KEYCODE_POWER
To swipe up for obtainging the PIN screen
adb shell input swipe 800 400 400 400
Enter PIN
adb shell input text 0000
Tap on Enter to unlock
adb shell input keyevent KEYCODE_ENTER
来源:https://stackoverflow.com/questions/40145397/unlock-android-mobile-with-pin-code-programmatically-selenium-mobile-automation