Search code examples
appium

Does driver.lockScreen method works?


I have called driver.lockScreen(20); in my script and then calling Runtime.getRuntime().exec("adb shell input keyevent 26"); to unlock screen.

But problem is, as I have specified 20 sec wait for lock screen, device is not getting locked for 20 sec. My next statement keyevent 26 is unlocking the device as soon as device is locked.

So

  • why we are providing 20 sec parameter?

Solution

  • This was an open issue on Github https://github.com/appium/java-client/issues/315

    Below are the updates (fixes) mentioned on Github for lockScreen bug:

    • The _AppiumDriver.lockScreen(int seconds)_ is deprecated now.

    • AndroidDriver: _lockDevice()_ and _unlockDevice()_ were added

    • IOSDriver: _lockDevice(int seconds)_ was added