Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Headless Selenium WebDriver with xvfbwrapper
#!/usr/bin/env python
from selenium import webdriver
from xvfbwrapper import Xvfb
# create a virtual display
vdisplay = Xvfb(width=1280, height=720)
vdisplay.start()
# do selenium stuff. look ma, no browser displayed!
browser = webdriver.Firefox()
browser.get('http://www.ubuntu.com')
assertIn('Ubuntu', browser.title)
# save a screenshot
browser.save_screenshot('screenie.png')
# quit browser instance
browser.quit()
# stop virtual display
vdisplay.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.