The reason you cannot run PyVirtualDisplay
on Windows is because PyVirtualDisplay uses Xvfb as it displays, and Xvfb is a dumb 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 Display(visible=True)
Or you can set the backend as shown in the API here .
My recommendation
Do not use; PyVirtualDisplay
you can use any webdriver, such as the Chrome driver, and just add ChromeOptions with --headless
.
Or in your case, you use firefox to look something like this:
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 information just look here .
Hope this helps you!