Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 80 lines (57 sloc) 2.905 kb
a33d8a2 @OniOni Added preliminary README.
authored
1 # python-parallel-wd -- Run selenium test in multiple browsers easily - Python flavor
2
1dfb00c @OniOni Add travis badge.
authored
3 ## Status
4 [![Build Status](https://travis-ci.org/OniOni/python-parallel-wd.png?branch=master)](https://travis-ci.org/OniOni/python-parallel-wd)
5
a33d8a2 @OniOni Added preliminary README.
authored
6 ## Install
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
7 ```shell
1dfb00c @OniOni Add travis badge.
authored
8 pip install python-wd-parallel
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
9 ```
a33d8a2 @OniOni Added preliminary README.
authored
10
11 ## Authors
12
1dfb00c @OniOni Add travis badge.
authored
13 - Mathieu Sabourin ([OniOni](http://github.com/OniOni))
a33d8a2 @OniOni Added preliminary README.
authored
14
15 ## License
16
17 * License - Apache 2: http://www.apache.org/licenses/LICENSE-2.0
18
6a777d8 @OniOni Fuller README, missing some links.
authored
19 ## Writing a test !
a33d8a2 @OniOni Added preliminary README.
authored
20
1dfb00c @OniOni Add travis badge.
authored
21 Start by importing the module
a33d8a2 @OniOni Added preliminary README.
authored
22
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
23 ```python
a33d8a2 @OniOni Added preliminary README.
authored
24 import wd.parallel
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
25 ```
a33d8a2 @OniOni Added preliminary README.
authored
26
1dfb00c @OniOni Add travis badge.
authored
27 The test should be implemented as a unittest TestCase. So go ahead and do that
6a777d8 @OniOni Fuller README, missing some links.
authored
28
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
29 ```python
a33d8a2 @OniOni Added preliminary README.
authored
30 class Selenium2OnSauce(unittest.TestCase):
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
31 ```
6a777d8 @OniOni Fuller README, missing some links.
authored
32
33 In the set up you should create your browsers configurations. Or you could just load them from a json file.
34
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
35 ```python
a33d8a2 @OniOni Added preliminary README.
authored
36 def setUp(self):
37 self.drivers = wd.parallel.Remote()
43dd024 @OniOni Removed reference to PATH method in readme.
authored
38 self.drivers.load_config_file(/path/to/your/config/file.json)
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
39 ```
6a777d8 @OniOni Fuller README, missing some links.
authored
40
8a1fcd0 @OniOni Corrected typo + added links to webdriver doc.
authored
41 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 <a href='http://code.google.com/p/selenium/wiki/PythonBindings'>selenium</a> documentation for available methods.
a33d8a2 @OniOni Added preliminary README.
authored
42
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
43 ```python
a33d8a2 @OniOni Added preliminary README.
authored
44 @wd.parallel.multiply
45 def test_sauce(self):
46 self.driver.get('http://saucelabs.com/test/guinea-pig')
47 self.assertTrue("I am a page title - Sauce Labs" in self.driver.title);
48 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')
49 self.driver.find_element_by_id('submit').click()
50
51 comments = self.driver.find_element_by_id('your_comments')
52 self.assertTrue('Your comments: Hello! I am some example comments. I should appear in the page after you submit the form' in comments.text)
53 body = self.driver.find_element_by_xpath('//body')
54 self.assertFalse('I am some other page content' in body.text)
55 self.driver.find_elements_by_link_text('i am a link')[0].click()
56 body = self.driver.find_element_by_xpath('//body')
57 self.assertTrue('I am some other page content' in body.text)
58
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
59 ```
6a777d8 @OniOni Fuller README, missing some links.
authored
60
61 The tear down method works just like the test cases. Just work as if there was one browser and add the @multiply decorator.
62
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
63 ```python
a33d8a2 @OniOni Added preliminary README.
authored
64 @wd.parallel.multiply
65 def tearDown(self):
66 self.driver.quit()
67
68 if __name__ == '__main__':
69 unittest.main()
d341739 @OniOni Added installation instructions and changed code blocks to allow syntax ...
authored
70 ```
a33d8a2 @OniOni Added preliminary README.
authored
71
72 ## Supported Methods
8a1fcd0 @OniOni Corrected typo + added links to webdriver doc.
authored
73 Check out the python wd <a href='http://code.google.com/p/selenium/wiki/PythonBindings'>implementation</a> it has all the documentation about actual tests.
a33d8a2 @OniOni Added preliminary README.
authored
74
75 ## More docs!
76 <pre>
77 WD is simply implementing the Selenium JsonWireProtocol, for more details see the official docs:
78 - <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol">http://code.google.com/p/selenium/wiki/JsonWireProtocol</a>
79 </pre>
Something went wrong with that request. Please try again.