Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to lock screen using playwright-android? #5216

Closed
NareshMurthy opened this issue Jan 29, 2021 · 8 comments · Fixed by #5331
Closed

[Question] How to lock screen using playwright-android? #5216

NareshMurthy opened this issue Jan 29, 2021 · 8 comments · Fixed by #5331

Comments

@NareshMurthy
Copy link
Contributor

How do I ( lock screen / swipe down the notification center / press recent apps button ) using playwright android?
Thanks!

@pavelfeldman
Copy link
Member

Here is the list of buttons you can press, I would start with the Power and then swipe?

https://github.com/microsoft/playwright/blob/master/types/android.d.ts#L119

@NareshMurthy
Copy link
Contributor Author

Tried to lock with await device.press("Power"); and await device.press("body", "Power");
Throws me error, could you let me know, if I am doing anything wrong here.

@pavelfeldman
Copy link
Member

pavelfeldman commented Jan 30, 2021

await device.input.press('Power'); - since your action is not associated with any UI element, you just perform this event globally.

@NareshMurthy
Copy link
Contributor Author

@pavelfeldman Thanks, I was able to lock using await device.input.press("Power"); , Is there a Key for recent app switcher?
After spending some time, I was able to swipe down the notification drawer with

await device.input.swipe(
    { x: 1, y: 1 },
    [
      { x: 1, y: 10 },
      { x: 1, y: 80 },
    ],
    2
  );

But not sure if its the right way, is there any documentation for playwright-android so that i can look in to?

@pavelfeldman
Copy link
Member

@NareshMurthy : swipecorresponds to UiDevice.swipe I can also see wakeUp there that we did not plumb. Tell us if there are more methods you'd like to see on device!

@pavelfeldman
Copy link
Member

Looks like you would want sleep, wakeUp and recentApps as well...

@NareshMurthy
Copy link
Contributor Author

Yes! I am looking for a recentApps button as well

@NareshMurthy
Copy link
Contributor Author

@pavelfeldman I have a test page, which captures active user time on the page, I noticed that, even after locking the screen / pulling down the notification bar, doesn't change the visibilityState of the page.
Something similar to this #2286

Thanks!

NareshMurthy added a commit to NareshMurthy/playwright that referenced this issue Feb 5, 2021
Added a new android key - RecentApps
Fixes microsoft#5216
NareshMurthy added a commit to NareshMurthy/playwright that referenced this issue Feb 6, 2021
Added new android keys for playwright-android - AppSwitch, Assist, Cut, Copy, Paste
Modified a android key from 'At' to '@'
Fixes microsoft#5216
pavelfeldman pushed a commit to NareshMurthy/playwright that referenced this issue Feb 16, 2021
Added a new android key - RecentApps
Fixes microsoft#5216
pavelfeldman pushed a commit to NareshMurthy/playwright that referenced this issue Feb 16, 2021
Added new android keys for playwright-android - AppSwitch, Assist, Cut, Copy, Paste
Modified a android key from 'At' to '@'
Fixes microsoft#5216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants