Skip to content

Commit

Permalink
Added installation instructions and changed code blocks to allow synt…
Browse files Browse the repository at this point in the history
…ax highlighting.
  • Loading branch information
OniOni committed Jun 5, 2012
1 parent 263ed35 commit d341739
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions README.md
@@ -1,7 +1,9 @@
# python-parallel-wd -- Run selenium test in multiple browsers easily - Python flavor

## Install
...
```shell
pip install python-wd-parallel
```

## Authors

Expand All @@ -11,34 +13,31 @@

* License - Apache 2: http://www.apache.org/licenses/LICENSE-2.0

## Usage
...

## Writing a test !

Start by importing the module

<pre>
```python
import wd.parallel
</pre>
```

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

<pre>
```python
class Selenium2OnSauce(unittest.TestCase):
</pre>
```

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

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

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.

<pre>
```python
@wd.parallel.multiply
def test_sauce(self):
self.driver.get('http://saucelabs.com/test/guinea-pig')
Expand All @@ -54,18 +53,18 @@ Now just write your test as you would for a unique browser. Test should be run o
body = self.driver.find_element_by_xpath('//body')
self.assertTrue('I am some other page content' in body.text)

</pre>
```

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

<pre>
```python
@wd.parallel.multiply
def tearDown(self):
self.driver.quit()

if __name__ == '__main__':
unittest.main()
</pre>
```

## Supported Methods
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.
Expand Down

0 comments on commit d341739

Please sign in to comment.