Skip to content

driver.lockScreen() not working as expected. #315

Closed

Description

@namannigam-zz

Quoting from SO-35223434-
We have called driver.lockScreen(20); in my test followed by Runtime.getRuntime().exec("adb shell input keyevent 26"); to unlock screen. But the problem is the device is not getting locked for 20 sec. The next statement keyevent 26 is unlocking the device as soon as device is locked. So why we are providing 20 sec parameter?
Looking further into this, the AppiumDriver.java has this to say :
/** * Lock the device (bring it to the lock screen) for a given number of * seconds * * @param seconds * number of seconds to lock the screen for */ public void lockScreen(int seconds) { execute(LOCK, ImmutableMap.of("seconds", seconds)); }

Activity

  1. TikhomirovSergey commented on Feb 7, 2016

    @TikhomirovSergey
    Contributor

    I will try to reproduce. But it can be the server-side problem.

  2. TikhomirovSergey commented on Feb 7, 2016

    @TikhomirovSergey
    Contributor

    It is the server side problem.
    appium/appium#6077

  3. namannigam-zz commented on Feb 7, 2016

    @namannigam-zz
    Author

    @TikhomirovSergey there's definitely some issue with the lockScreen() but just to clear the appium/appium#6077 depicts that the screen remains locked. While in our case the screen does not remain lock for the specified sleep time.

  4. TikhomirovSergey commented on Feb 7, 2016

    @TikhomirovSergey
    Contributor

    While in our case the screen does not remain lock for the specified sleep time.

    I'm searching for the cause of this problem. It is already reported probably. I've asked the question at team chat.

  5. imurchie commented on Feb 9, 2016

    @imurchie
    Contributor

    Talking this over, this appears to be the desired behavior. The locking-waiting-unlocking is necessary for iOS, where it is the only way to do any locking. For Android it should just lock. If you want it to unlock, you can call unlock.

    I am making the seconds parameter optional, and documenting this difference.

  6. added a commit that references this issue on Feb 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions