6

Hi I am planning to setup selenium to test my web application.

I have read that both chromedriver and Xvfb can be used to run the tests. I have also read that Xvfb can be configured to use chromdriver.

So that got me confused. What role does chromedriver and Xvfb in runnning the selenium tests.

Thanks

Aniket
  • 4,926
  • 12
  • 41
  • 54

1 Answers1

10
  1. chromedriver - to run tests on chrome browser (with GUI).
  2. Xvfb - to run tests in headless mode. can be any browser including chrome (Browser GUI won't be displayed, so you can use the machine for some other operations).

code snippets (python):

Chrome Driver (download here):

browser = webdriver.Chrome() // to launch tests in Chrome browser.

Xvfb - using pyvirtualdisplay (python wrapper for Xvfb) :

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

# now Chrome will run in a virtual display. 
# you will not see the browser.
browser = webdriver.Chrome()
browser.get('http://www.google.com')
print browser.title
browser.quit()

display.stop()

References:

  1. How do I run Selenium in Xvfb?
Community
  • 1
  • 1
Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
  • This doesn't work on a desktop. It just launches a conventional browser, even though `visible=0` is specified. How do you test with this on a system with an active X server? How does Selenium know to use the Xvfb wrapper instead of the default DISPLAY connection? – Cerin Feb 22 '22 at 00:28
  • Hi Cerin, were you able to figure out how to launch Xvfb on your local desktop... I'm meeting a similar issue to yours... – Upchanges Apr 29 '23 at 14:47