Fullscreen in Headless Chrome using Selenium [duplicate]

扶醉桌前 提交于 2021-02-05 09:26:18

问题


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 600px size ignoring the customized --window-size arguments.



来源:https://stackoverflow.com/questions/64865986/fullscreen-in-headless-chrome-using-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!