Chrome Options in Python Selenium : Disable GPU vs Headless

房东的猫 提交于 2020-01-21 11:20:40

问题


In python-selenium chrome_options, What exactly is the difference between the following two options, I know both runs the selenium script without opening the browser.

chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

回答1:


You saw it right. Adding the argument --headless initiates the Chrome Browsing Context in headless mode.

However the purpose of the argument --disable-gpu was to enable google-chrome-headless on windows platform. It was needed as SwiftShader fails an assert on Windows in headless mode earlier.

This issue was resolved through Headless: make --disable-gpu flag unnecessary

You can find a relevant detailed discussion in ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode




回答2:


--disable-gpu doesn't run the script without opening the browser, only --headless. It used to be needed on Windows Issue 737678: Headless: make --disable-gpu flag unnecessary, but this bug was fixed. chrome_options.add_argument('--headless') is all you need.



来源:https://stackoverflow.com/questions/59047415/chrome-options-in-python-selenium-disable-gpu-vs-headless

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