Installing Xvfb in Centos 6, 7, Fedora

Xvfb, or X virtual frame buffer is needed by selenium and chromedriver or gekodriver so it can run via cron with your PC locked, or without your script taking focus from the user session

The Xvfb, or "X virtual frame buffer" will allow scripts and apps to run within their own virtual x windows session. It allows you to write chromedriver scripts to do cool things on the web, and run them without them stealing focus in your local session.

# yum install -f chromedriver chromium xorg-x11-server-Xvfb
Example Python utilizing a virtual framebuffer:
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 800))
outputdir = "/tmp"
options = webdriver.ChromeOptions()
options.binary_location = '/bin/google-chrome'
service_log_path = "{}/chromedriver.download_tax_rates.log".format(outputdir)
service_args = ['--verbose']
driver = webdriver.Chrome('/bin/chromedriver',

#open connection
# driver = webdriver.Chrome()
#open chrome to first page

Update - 2019, in the example above, I used chromedriver as a use case. I notice this page gets a ton of hits on google, so I wanted to make sure my users knew about chromedrivers new headless argument.

here's an example speedtest app I wrote utilizing this headless argument. It makes for much faster apps, without needing to use an XVFB. By all means use the older XVFB option if needed. I'm just pointing out a better way than the original example. Thanks!

Webdriver give you some amazing power in development. I've seen some amazing things built with it.

Example Python3 without needing a virtual framebuffer:
from selenium import webdriver
import as service
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome'
service_args = ['--verbose', '--disable-application-cache']
driver = webdriver.Chrome('/usr/bin/chromedriver',
# open page
print("opening browser")

# sleep for page load

## click more info
print("clicking show details link")
clickme = driver.find_element_by_css_selector('#show-more-details-link')
# wait for download speed test to finish
print("waiting for results")

# lets grab the following info
dl_speed = driver.find_element_by_css_selector('#speed-value')
up_speed = driver.find_element_by_css_selector('#upload-value')
dl_total = driver.find_element_by_css_selector('#down-mb-value')
ul_total = driver.find_element_by_css_selector('#up-mb-value')
ul_ping = driver.find_element_by_css_selector('#latency-value')
lo_ping = driver.find_element_by_css_selector('#bufferbloat-value')
usr_ip = driver.find_element_by_css_selector('#user-ip')
usr_isp = driver.find_element_by_css_selector('#user-isp')
server = driver.find_element_by_css_selector('#server-locations')

download_speed = dl_speed.text
upload_speed = up_speed.text
download_total = dl_total.text
upload_total = ul_total.text
unloaded_ping = ul_ping.text
loaded_ping = lo_ping.text
user_ip = usr_ip.text
user_isp = usr_isp.text
server_info = server.text

print("download speed: " + download_speed + " Mbps.")
print("upload speed: " +  upload_speed + " Mbps.")
print("download total: " + download_total + " megabytes downloaded for test")
print("upload total: " + upload_total + " megabytes uploaded for test")
print("unloaded ping: " + unloaded_ping + " ms.")
print("loaded ping: " + loaded_ping + " ms.")
print("user ip: " + user_ip)
print("user isp: " + user_isp)


These examples are also tested to work in RHEL6, RHEL7, Fedora Server, Fedora Workstation later releases. My normal non work envornment is Fedroa normally.

comments powered by Disqus