使用 Selenium 在 Headless Chrome 中全屏显示 [英] Fullscreen in Headless Chrome using Selenium
问题描述
我在 E2E 套件中进行了许多测试,其中视频元素全屏显示并验证全屏状态.但是,在无头运行套件时,这些测试会失败.该页面的屏幕截图显示视频根本没有全屏显示,即使在单击全屏按钮后也是如此.有没有办法在无头 Chrome 中实现全屏功能?
这是我的配置中的功能示例.
功能:[{'浏览器名称':'铬','goog:chromeOptions': {args: ['无头']}}]
当添加参数 --start-fullscreen
来初始化
虽然
结论
因此可以得出结论,在--headless
模式下,Chrome浏览器总是以800
x 600
px 大小忽略自定义的 --window-size
参数.
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']
}
}
]
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.
这篇关于使用 Selenium 在 Headless Chrome 中全屏显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!