Chrome "--headless=new" mode does not allow to apply "--window-size" option - google-chrome

When new chrome headless mode is used the "--windows-size=width,height" argument doesn't work.
For example:
"--headless=new",
"--window-size=1920,1080"
Running tests with these arguments produces strange size screenshots: 1028x653 px
But with the old headless mode:
"--headless",
"--window-size=1920,1080"
the screenshots size is OK: 1920x1080 px.
I can't use old mode, because the files downloading is not working in it anymore, here is the post about it, where using the new headless mode is suggest as a solution: Downloading with chrome headless and selenium

Are you running your tests with a CI-Tool like Jenkins?
I see a similar behavior (messing up the screen size) only with a central run on Jenkins, like always..local it works.
If so I think it has to do with the system user the test is executed through a jenkins agent.

This is a bug being fixed in Chrome. You can see the status of the fix and the reasons here:
https://bugs.chromium.org/p/chromium/issues/detail?id=1416398

Related

How to set the device type (to not mobile) when inspecting a remote target with Chrome DevTools?

So it seems that the device toolbar usually present in any regular DevTools instance is missing when inspecting a remote instance.
And in such cases the device type is set to "Mobile", with the mouse pointer set to a circle, as to indicate that.
Here's how to reproduce this:
start a new headless instance, e.g., with:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --headless https://example.com
using another Chrome instance navigate to chrome://inspect and inspect the remote tab.
as you can see there is no device toolbar.
I also tried to send some Chrome DevTools Protocol commands like:
Emulation.setTouchEmulationEnabled
Emulation.setEmitTouchEventsForMouse
Emulation.setDeviceMetricsOverride
But to no avail, something happens but the behavior looks broken... I suspect that this is something concerning the DevTools frontend, and not the inspected Chrome instance.
Do you have any idea about how can I work around this? My ultimate goal is to manually interact with a remote headless instance using a desktop device type.
If I understand you correctly, you want to do manual interactions with a remote instance using a desktop device. You should just be able to click the device icon at the top left of your devtools window to turn off mobile.

Issues faced while Using Chrome Headless Browser in testing

The Chrome Headless browser was unable to identify the element even it is mentioned with an id in the test case. While running the same test case in chrome browser,
it was working perfectly fine and was failing when I try to run the test case using Chrome Headless Browser. I have set the window size for the chrome headless Browser even the results were same.
Unable to find the element located by ‘By.xpath: //input[#id =
‘tipo_meta-display_name’]’. Please recheck the objects properties to
make sure the desired element is located.
Can anyone help me with the issue

Google Chrome push-notifications without browser running

Does anybody know how to implement receiving of push notifications outside and without running browser?
There is some nuance to this:
Chrome for Android: Push messages will wake up the Service Worker and Web App even if the browser is closed. This is the default and our ideal position across all platforms
Desktop Chrome: Push works and will wake up the service worker if the browser is still open. However it will not work if the browser is closed. You can force the browser to remain open if you have a Chrome App that is set to run in the background. Other than that we (the Chrome team) are working out how we enable this by default on Windows, Mac and Linux.
Chrome for iOS: Push just does not work on this platform
Chromium blog has a post with code examples: http://updates.html5rocks.com/2015/03/push-notificatons-on-the-open-web
And the documentation was updated too: https://developer.chrome.com/apps/cloudMessaging
It is possible to write Chrome extension where background script can run if Chrome is allowed to run in the background (configurable in settings) and it can use GCM.

Chrome settings - set "emulate touch events" as default settings

We are trying to run some automated tests (coded ui based) on our mobile application via Chrome browser.
In order to make the tests available to run, we must set the browser to work as 'emulate touch events'.
The thing is that as part of our test flow, a new chrome browser is being launched on each test but the definition is gone.
I already check this one, but it doesn't work:
How to Always Emulate Touch Events in Chrome Dev Tools?
Any other suggestions?
Thanks,
Yair
I believe that the dev tools window must be opened for the overrides to kick in, have you tried that?

Can i resize Chrome window using the console?

Is it possible to resize the Chrome window using the developer tool's console? If so, what would the command be? becuase the window.resizeTo(w,h) didn't work for me.
Official Chrome issue says:
By Design we don't support resize/move for tabs, only constrained windows.
Windows in Chrome can be resized via Chrome extensions API, however it's not available from console. You should probably try using one of many 'window resizing' extensions. In the near future it will be possible for extensions to add own console commands, however as for now it's an experimental feature.
i think you can only resize windows that's you have created from the console, like popups
for example:
var pop=window.open("","","width=1024,height=768");
pop.resizeTo(100,100);
On macOS you can run: open -a Google\ Chrome --args --window-size=1366,768
Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser, according to the following rules:
You can't resize a window or tab that wasn’t created by window.open.
You can't resize a window or tab when it’s in a window with more than one tab.
found on https://developer.mozilla.org/en-US/docs/DOM/window.resizeTo#Notes
some try and error seems to prove that these rules also apply in Chrome.