Is there a Windows equivalent to PyVirtualDisplay

霸气de小男生 提交于 2019-12-01 03:32:10

The reason you can not run PyVirtualDisplay on Windows is that PyVirtualDisplay uses Xvfb as it's display and Xvfb is a headless display server for the X Window System, Windows does not use the X Window System.

not recommended

So... what you can do if you insist on working with PyVirtualDisplay is to change the Display(visible=True) Or you can set the backend as is shown in the API here.

My recommendation

Don't use PyVirtualDisplay you can use any webdriver such as Chrome driver and just add ChromeOptions with --headless.

Or in your case you use firefox so it would look something like:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
print("Firefox Headless Browser Invoked")
driver.get('http://google.com/')
driver.quit()

For more updated info just have a look here.

Hope this helps you!

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