Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Run selenium tests in multiple browsers with minimum hastle. Python flavor !

branch: master
README.md

python-parallel-wd -- Run selenium test in multiple browsers easily - Python flavor

Status

Build Status

Install

pip install python-wd-parallel

Authors

License

Writing a test !

Start by importing the module

import wd.parallel

The test should be implemented as a unittest TestCase. So go ahead and do that

class Selenium2OnSauce(unittest.TestCase):

In the set up you should create your browsers configurations. Or you could just load them from a json file.

    def setUp(self):
        self.drivers = wd.parallel.Remote()
        self.drivers.load_config_file(/path/to/your/config/file.json)

Now just write your test as you would for a unique browser. Test should be run on the self.driver attribute. Just use the @multiply decoration to run the test in all the browser you set up. Check out the selenium documentation for available methods.

    @wd.parallel.multiply
    def test_sauce(self):
        self.driver.get('http://saucelabs.com/test/guinea-pig')
        self.assertTrue("I am a page title - Sauce Labs" in self.driver.title);
        self.driver.find_element_by_id('comments').send_keys('Hello! I am some example comments. I should appear in the page after you submit the form')
        self.driver.find_element_by_id('submit').click()

        comments = self.driver.find_element_by_id('your_comments')
        self.assertTrue('Your comments: Hello! I am some example comments. I should appear in the page after you submit the form' in comments.text)
        body = self.driver.find_element_by_xpath('//body')
        self.assertFalse('I am some other page content' in body.text)
        self.driver.find_elements_by_link_text('i am a link')[0].click()
        body = self.driver.find_element_by_xpath('//body')
        self.assertTrue('I am some other page content' in body.text)

The tear down method works just like the test cases. Just work as if there was one browser and add the @multiply decorator.

    @wd.parallel.multiply
    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()

Supported Methods

Check out the python wd implementation it has all the documentation about actual tests.

More docs!

WD is simply implementing the Selenium JsonWireProtocol, for more details see the official docs:
 - http://code.google.com/p/selenium/wiki/JsonWireProtocol
Something went wrong with that request. Please try again.