Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 365
Aniket Avatar asked Jan 04 '17 09:01

Aniket


People also ask

Why is XVFB used?

Xvfb (short for X virtual framebuffer) is an in-memory display server for UNIX-like operating system (e.g., Linux). It enables you to run graphical applications without a display (e.g., browser tests on a CI server) while also having the ability to take screenshots.

What is difference between ChromeDriver and WebDriver?

WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server that implements the W3C WebDriver standard.

Why do we use ChromeDriver?

Why do you need ChromeDriver? The main purpose of the ChromeDriver is to launch Google Chrome. Without that, it is not possible to execute Selenium test scripts in Google Chrome as well as automate any web application. This is the main reason why you need ChromeDriver to run test cases on Google Chrome browser.

Is Chrome and ChromeDriver same?

ChromeDriver uses the same version number scheme as Chrome. See https://www.chromium.org/developers/version-numbers for more details. Each version of ChromeDriver supports Chrome with matching major, minor, and build version numbers. For example, ChromeDriver 73.0.


1 Answers

  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?
like image 162
Naveen Kumar R B Avatar answered Oct 23 '22 09:10

Naveen Kumar R B