Created
November 27, 2012 00:12
-
-
Save cgoldberg/4151527 to your computer and use it in GitHub Desktop.
Python xvfbwrapper example: Headless Selenium WebDriver Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from selenium import webdriver | |
from xvfbwrapper import Xvfb | |
import unittest | |
class TestHomepages(unittest.TestCase): | |
def setUp(self): | |
self.vdisplay = Xvfb(width=1280, height=720) | |
self.vdisplay.start() | |
self.browser = webdriver.Firefox() | |
def testUbuntuHomepage(self): | |
self.browser.get('http://www.ubuntu.com') | |
self.assertIn('Ubuntu', self.browser.title) | |
def testGoogleHomepage(self): | |
self.browser.get('http://www.google.com') | |
self.assertIn('Google', self.browser.title) | |
def tearDown(self): | |
self.browser.quit() | |
self.vdisplay.stop() | |
if __name__ == '__main__': | |
unittest.main(verbosity=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment