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

[Feature] Run Playwright tests on real mobile device browsers? #1122

Open
Cosmin-Gramada opened this issue Feb 26, 2020 · 70 comments
Open

[Feature] Run Playwright tests on real mobile device browsers? #1122

Cosmin-Gramada opened this issue Feb 26, 2020 · 70 comments

Comments

@Cosmin-Gramada
Copy link

Cosmin-Gramada commented Feb 26, 2020

Is there any way to connect to a device, start a browser (e.g. chromium instance on Android) and run the tests?

If not, what is missing at this point to be able to use it on both Android and iOS?


Note from maintainers:

Please refer to the https://playwright.dev/docs/next/api/class-android for
instructions on how to use Playwright with Chrome for Android, Android
WebViews and Android itself


@pavelfeldman
Copy link
Member

There is no way to attach to Chromium on Android or MobileSafari on iOS. Playwright aims at running on your desktop and in your CI/CD, targeting device farms is outside its scope.

We will emulate device metrics, geolocation, orientation, etc on Chromium on Android and MobileSafari though. Could you share more about your use case?

@Cosmin-Gramada
Copy link
Author

We took into account the possibility of moving away from Selenium WebDriver based tools and switching to DevTools API based tools.

A really big portion of our tests are running on mobile web browsers, where we tests our own player that makes use of browser related technologies (e.g. what types of medias is able to render, what's the appropriate format, etc) and sends specific tracking events.

Our concern is that there will be differences between a real device and an emulated one, as we're able to emulate any device resolution, but only the viewport size is guaranteed to be accurate.

@pavelfeldman
Copy link
Member

Our concern is that there will be differences between a real device and an emulated one

Yes, there will be

as we're able to emulate any device resolution, but only the viewport size is guaranteed to be accurate

More than the viewport size, but yes, if you need mobile-specific media to be accurate, you need to attach to the device.

This is technically feasible, but is outside of the scope for v1.

@tanaypratap
Copy link

This could be useful for us too. We are a fully fledged PWA email app. Testing on actual devices would catch bugs. We have also faced this issue with non-existent media queries on some phones which @Cosmin-Gramada mentioned. Especially older phones.

@Filipoliko
Copy link

Filipoliko commented Apr 21, 2020

Since Playwright is trying to be more testing-friendly, it would be really great to have real mobile device support. More and more users are coming to our websites from mobile devices, it is nearly 50:50 for us. Most of our bugs on mobile devices are not discoverable via simple mobile emulation. It is really important for us to be able to test on real mobile devices, or at least on emulated Android/iOS systems.

@arjunattam
Copy link
Contributor

@Filipoliko - thank you for sharing. Can you elaborate on which bugs are not discoverable via emulation? Examples will really help!

@Filipoliko
Copy link

@arjun27 - They are usually some very specific (and kinda weird) use cases, typically on iOS devices. One current bug on our website, that is discoverable only on real iOS device (safari, or chrome) can be currently found on this page. (The fix will be probably released during next week, hopefully you can check it before that time).

If you click on Domácí (see the picture below), then with chrome mobile emulation, you will be redirected to a section page Domácí (correct behaviour). But if you are running chrome, or safari on real iOS device, then the click will open the mobile menu. This is fixed by setting pointer-events: none on the hidden mobile menu element. Android/Windows/macOS works fine, but iOS requires this css rule for some reason.

image

Probably most typical use cases (as far as I can think of) are related to some invisible elements overlapping other elements and making it impossible to click on the overlapped element. This behaviour is usually iOS specific, other systems interpret these css rules in a bit different way.

@arjunattam
Copy link
Contributor

Thanks @Filipoliko. I just tried running this case with iPhone emulation on Playwright WebKit and I'm able to repro this issue. Chrome mobile emulation is not reproducing it, as you've rightly pointed it out. Also, you're right about an invisible overlapping element (which is why I had to use force: true to issue the click). Sharing code below in case you'd like to try it out.

const { webkit, devices } = require('playwright');

(async() => {
  const browser = await webkit.launch({headless: false});
  const context = await browser.newContext({...devices['iPhone 11 Pro']});
  const page = await context.newPage();
  await page.goto('https://www.seznamzpravy.cz/clanek/v-korupcni-kauze-stoka-obvinila-policie-dalsi-27-lidi-111820');
  await page.click('[data-dot="ogm-breadcrumb-navigation"] >> text=Domácí', {force: true});
})();

Screen Shot 2020-07-08 at 9 34 53 AM

@Kradirhamik
Copy link

Hi,

I would like to also give support for this idea. Our use cases requires our Angular site to get input from other apps (e.g. BankID for authentication). So the real flow can only be properly tested on a real device.

@dgozman dgozman changed the title [Question] Is it possible to run Playwright tests on real mobile device browsers? [Feature] Run Playwright tests on real mobile device browsers? Nov 24, 2020
@alejandroiglesias
Copy link

alejandroiglesias commented Dec 2, 2020

Hi,
I'm curious to know what the workflow is on this project for an issue like this to move from feature request to development by the team? Does it need to reach a certain amount of upvotes? Does it need any funding? Does it take a certain amount of time to pass, like waiting for the next major release planning? It would be good for users to know and be able to set expectations on the development of feature requests. Thanks!

@pavelfeldman
Copy link
Member

We have already seen enough interest in it, so we will invest into this area. There are several questions about the use cases and the API, so we would appreciate your feedback, the more details the better. I'll post some initial questions below as comments, please upvote them in case they apply!

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if you'd like to

Use Playwright with the Chrome Browser (WebView integration is not essential for you).

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if you'd like to

Use Playwright against your WebView and can bring WebView into a testable state over adb.

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if you'd like to

Use Playwright against AVD (Emulator) as opposed to the real device.

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if you'd like to

Use Playwright against the physical device as opposed to AVD (Emulator).

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if

Your testing setup requires Android w/ Play Store

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

Please 👍 if

Your testing setup does not require Android w/ Play Store

@pavelfeldman
Copy link
Member

Please 👍 if

You intend to run tests in the cloud.

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 6, 2020

See https://playwright.dev/docs/api/class-android for experimental support.

@pavelfeldman
Copy link
Member

pavelfeldman commented Dec 10, 2020

Folks, npm i playwright-android is now live and it has a first cut of the support for Android's Chrome browser as well as WebViews. It has not been covered with the tests, neither it runs on the bots. But it does work for simple scenarios. Please let us know if it works for you or if something is missing. As a drive-by it includes uiautomator-alike driver for the Android itself.

Edit: Please reference to the guide here: https://playwright.dev/docs/api/class-android

@alejandroiglesias
Copy link

alejandroiglesias commented Dec 11, 2020

@pavelfeldman that's great! Thanks for the initial implementation efforts. Are there any plans to do the same for iOS Safari? That would be awesome to get the main mobile contenders covered. Also, do you know how/if this could work with @web/test-runner-browserstack (a test runner that supports Playwright)?

@vania-pooh
Copy link
Contributor

@alejandroiglesias so far as I know BrowserStack now supports Selenium protocol only.

@alejandroiglesias
Copy link

alejandroiglesias commented Dec 12, 2020

@vania-pooh BrowserStack also supports Cypress and has an HTTP-based API, and if @web/test-runner-browserstack does what it promises and can be combined with @web/test-runner-playwright, I would imagine that Playwright it should work in BrowserStack... in theory and unless I'm missing something. Alternatively, SauceLabs supports Playwright as it's stated in their docs.

@wahreChrist
Copy link

I would be content if we at least would have an option of having all the touch-based gestures on mobile viewports because right now there is only a built-in tap, which was added in version 1.8, and nothing besides that(no swipes, pinches, zooms, etc.).

@deepnaj
Copy link

deepnaj commented Sep 24, 2022

support on real mobile devices

@pranavj1001
Copy link
Contributor

pranavj1001 commented Sep 28, 2022

Please make it possible to test via browser stack on mobile devices as well. Browserstack is already supported, but only for desktop OS. I don't understand the problem, why it should not be possible on mobile devices on Browserstack.

vania-pooh is the browserstack integration something you would consider?

Hello everyone, looking at this issue and some other issues (here on github and on playwright slack channel), we can see that people are requesting support for running Playwright tests on cloud mobile devices (similar to the desktop Playwright tests).

We have raised a PR and a Feature Request for this. We are happy to collaborate on this.

@mehrad-rafigh
Copy link

I talked to Browserstack and they are currenlty working on the Android part. Its in a private alpha and I hope it will soon be in beta.
For our development efforts, it would be great to able to test on real iOS devices, as the majority of our users come from iOS devices.

@GrayedFox
Copy link

@pavelfeldman ahoy, I understand good things take time and am not asking for a specific timeline or anything, but I wanted to clarify a few things if that's alright:

  1. Do the playwright team plan on implementing iOS real mobile device support?
  2. Do the playwright team plan on implementing iOS real mobile cloud device testing support?

I tried accessing the beta mobile docs link but has moved (or been removed):

See https://github.com/microsoft/playwright/blob/master/docs/mobile.md for experimental support.

If experimental support has been added, or there is a nightly or dev build with such support, could you provide an up to date link?

Thanks all your hard work!

@sgnl
Copy link

sgnl commented Feb 21, 2023

I talked to Browserstack and they are currenlty working on the Android part. Its in a private alpha and I hope it will soon be in beta. For our development efforts, it would be great to able to test on real iOS devices, as the majority of our users come from iOS devices.

https://www.browserstack.com/blog/introducing-android-playwright/ in beta

@MRamonLeon
Copy link

See https://github.com/microsoft/playwright/blob/master/docs/mobile.md for experimental support.

This link is missed.
We want to test real gestures wit webkit and android-like browser (pinching, swiping, ...). The desktop browsers are not 100% reliable for this purpose. Thanks!

@flakey-bit
Copy link

This is possibly a dumb question, but would it be technically possible for Playwright to support the Webdriver protocol?

Or is this explicitly a non-goal for the Playwright project?

Naively, it seems like supporting Webdriver would unlock lots of possibilities (for example, running on real Safari on OSX)

@dantman
Copy link

dantman commented Mar 15, 2023

This is possibly a dumb question, but would it be technically possible for Playwright to support the Webdriver protocol?

I'd like to add to this question. Even if the full capabilities of Playwright are not possible, would it be possible to have partial support for it.

One of the things I like about TestCafe is how it supports basically any browser in a tiered structure. It has native support for a number of browsers. But can also run in many others like native mobile browsers, just with some features unavailable.

The ability to take a Playwright test and run it on any Webdriver compatible browser would be game changing. Even if it didn't have the full Playwright functionality.

e.g. It would be lovely if I could develop a robust set of feature tests in Playwright for the major browsers. Then run a partial set of those as smoke tests in a bunch of other browsers just to check for any browser specific bugs. Without needing to rewrite tests in a completely different framework.

@refactoreric
Copy link

This is possibly a dumb question, but would it be technically possible for Playwright to support the Webdriver protocol?

A Playwright fan's answer: From my understanding, a lot of Playwright's strengths like the efficient auto-waiting are relying on the protocol to be bi-directional. The current Webdriver protocol is too restricting and fundamentally different.
To enable Playwright-like features, the Webdriver team is working on the Webdriver BiDi protocol, but it still seems miles away.
If the Webdriver BiDi protocol (and support for it in browsers) catches up, then the Playwright dev team might start thinking about adding support for that protocol.

@andreagubellini
Copy link

is there any update on this?

@lauvers
Copy link

lauvers commented Dec 11, 2023

is there any update on this?

I would like to know this too. Where I work, we are looking into using Playwright for our test automation, but being able to test on real devices with iOS (e.g. using Browserstack) is a must have for some test cases.

@LuciaHMQA
Copy link

Please support android and ios native. Playwright is a wonderful tool to test automation and if support this mobile features is a one-tool-all-automation testing! the automation testing world need a tool with all automation phases.
Thank you!.

@dimkin-eu
Copy link

500+ 👍
Sounds like something so many people wants

@Xen0byte
Copy link

500+ 👍 Sounds like something so many people wants

Not only that, but it's the top most requested feature. I should probably add that for me and other non-TS peeps the problem is even worse, because let's say this gets added to the TS world, it still needs to be ported to other languages. e.g. in the .NET world where I use Playwright we don't even have Android support yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests