Closed geoffharcourt closed 4 years ago
Yes
I've managed to get this working in Selenium with a Chrome argument, but I haven't been able to get this to work via CDP even by hard-coding the settings in an Apparition branch. We're trying to set mobile: true
along with a lower resolution and Chrome doesn't open in the mobile emulation mode. This is quite important to us, so we're continuing to investigate what combination of settings we need in CDP to make this work.
You can always register a second driver instance, for mobile, passing the required chrome argument if this isn't possible via CDP
Yeah, that's what we're doing now, firing up Chromedriver for a handful of sensitive mobile tests. We love Apparition and have had a lot of improvement in stability using it, so I think this is worth digging a bit further. I'll see what we can do on our next housekeeping day.
I've gotten it to work. For my PR, I'm unsure of what the ideal way to pass these options in is from your perspective:
#resize
to pass device emulation parameters on to #set_viewport
#resize
to override device emulation parameters and pass them on to #set_viewport
We'd prefer #3 because for mobile scenarios we'd rather mark those specs to use a mobile browser from the start. I'm happy to do whatever you think would be most generally useful.
Chrome for a while has not allowed the user to shrink the window width narrower than a certain width (I think it's 500px on most displays). We had thought that our mobile tests were getting down to narrower widths, but it turns out they are blocked.
You can get narrower if you select a device to simulate from the developer tools.
It looks like CDP supports mobile device simulation, this would be a pretty awesome thing to be able to do in Apparition. It would probably require being able to pass
mobile
in as a parameter and then have it pass through to here: https://github.com/twalpole/apparition/blob/170a98529bb3d49ee1a4335b43c183ee2eb9de41/lib/capybara/apparition/page.rbhttps://developers.google.com/web/tools/chrome-devtools/device-mode
Would you be open to a PR to do this?