问题
I have a number of tests in an E2E suite where a video element is fullscreened and the fullscreen status is verified. However, when running the suite headlessly, these tests fail. Screenshots of the page show the video is simply not in fullscreen, even after the fullscreen button is clicked. Is there a way to achieve fullscreen functionality in headless Chrome?
Here is an example of the capabilities in my config.
capabilities: [
{
'browserName': 'chrome',
'goog:chromeOptions': {
args: ['headless']
}
}
]
回答1:
When the argument --start-fullscreen
is added to initialize google-chrome in normal mode it seems the screen size is:
1366 x 724px
Snapshot:
Whilst google-chrome-headless when initiated additionally with either of the arguments:
--start-maximized
--kiosk
--start-fullscreen
The resultant screen size is always:
800 x 600px
Snapshot:
Conclusion
So it can be concluded that in --headless
mode Chrome browser always opens in 800
x 600
px size ignoring the customized --window-size
arguments.
来源:https://stackoverflow.com/questions/64865986/fullscreen-in-headless-chrome-using-selenium