Xvfb on Windows
Asked Answered
T

2

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']
Tourcoing answered 12/12, 2016 at 10:53 Comment(3)
It seems there is no support for Xvfb on Windows. #21064333. Look for alternatives.Rockandroll
Can anyone please give me an alternative to run Firefox headless in Windows please?Tourcoing
Possible duplicate of Selenium running headless Firefox browser in WindowsLotuseater
H
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.

Hinson answered 12/12, 2016 at 20:31 Comment(1)
do you know of an alternative for Windows?Fortnightly
C
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
Charlottecharlottenburg answered 22/4, 2021 at 7:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.