11

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']
Ralk
  • 443
  • 1
  • 6
  • 17
  • It seems there is no support for Xvfb on Windows. http://stackoverflow.com/questions/21063833/python-xvfb-error-in-windows. Look for alternatives. – Naveen Kumar R B Dec 12 '16 at 12:36
  • Can anyone please give me an alternative to run Firefox headless in Windows please? – Ralk Dec 12 '16 at 12:43
  • 3
    Possible duplicate of [Selenium running headless Firefox browser in Windows](http://stackoverflow.com/questions/17062453/selenium-running-headless-firefox-browser-in-windows) – Klaus D. Dec 12 '16 at 13:33

2 Answers2

11

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.

Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
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
Robert Sinclair
  • 4,550
  • 2
  • 44
  • 46