Xvfb on Windows

17,308

Solution 1

You can't use pyvirtualdisplay on Windows.

It is just a wrapper that calls Xvfb. Xvfb is a headless display server for the X Window System. Windows does not use the X Window System.

Solution 2

For windows users you can use the free VNC utility.. For example if you are running docker you can do it in 3 steps:

  1. Run a docker image that has the standalone firefox server (that has port 5900 exposed for VNC)
    $ docker run -d -p 4444:4444 -p 5990:5990 selenium/standalone-firefox-debug
  1. Open VNC and connect to that host localhost:5990, password is 'secret'

enter image description here

  1. Now simply execute your selenium script and you will see what's happening in VNC window live as its happening. Just make sure the script is pointing to your docker standalone server like localhost:4444/wd/hub in order for it to work
Share:
17,308

Related videos on Youtube

Ralk
Author by

Ralk

Updated on July 03, 2022

Comments

  • Ralk
    Ralk almost 2 years

    I'm using pyvirtualdisplay to run a test with a headless Firefox browser. This is the code I'm using :

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from pyvirtualdisplay import Display
    
    display= Display(visible=0, size=(320, 240)).start()  # visible=0
    display.start()
    driver = webdriver.Firefox()
    driver.get("https://google.com")
    
    display.quit()
    

    And the traceback that I obtain :

    easyprocess.EasyProcessCheckInstalledError: cmd=['Xvfb','-help']
    
  • HenryM
    HenryM almost 7 years
    do you know of an alternative for Windows?