What is difference between Xvfb and Chromedriver and when to use them What is difference between Xvfb and Chromedriver and when to use them selenium selenium

What is difference between Xvfb and Chromedriver and when to use them


  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 Displayfrom selenium import webdriverdisplay = 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.titlebrowser.quit()display.stop()

References:

  1. How do I run Selenium in Xvfb?