Skip to content

Commit a4ae015

Browse files
simple example
1 parent 6d442ff commit a4ae015

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,45 @@ It is also possible to use `TESTINGBOT_KEY` and `TESTINGBOT_SECRET` environment
3131
## Running tests
3232

3333
This library is only intended to query the TestingBot API.
34-
To run Selenium RC/WebDriver tests with Python, please see [Python WebDriver Examples](http://testingbot.com/support/getting-started/python.html)
34+
Below is a simple example which runs a Selenium Webdriver test on TestingBot and reports its name/success state back to TestingBot via this library:
35+
36+
```python
37+
import unittest
38+
import sys
39+
40+
from selenium import webdriver
41+
from selenium.webdriver.common.keys import Keys
42+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
43+
from testingbotclient import TestingBotClient
44+
45+
class TestTestingBotClient(unittest.TestCase):
46+
47+
def setUp(self):
48+
desired_cap = {'platform': 'Windows', 'browserName': 'firefox', 'version': '35' }
49+
50+
self.driver = webdriver.Remote(
51+
command_executor='http://key:[email protected]/wd/hub',
52+
desired_capabilities=desired_cap)
53+
54+
def test_google_example(self):
55+
self.driver.get("http://www.google.com")
56+
if not "Google" in self.driver.title:
57+
raise Exception("Unable to load google page!")
58+
elem = self.driver.find_element_by_name("q")
59+
elem.send_keys("TestingBot")
60+
elem.submit()
61+
62+
def tearDown(self):
63+
self.driver.quit()
64+
status = sys.exc_info() == (None, None, None)
65+
tb_client = TestingBotClient('key', 'secret')
66+
tb_client.tests.update_test(self.driver.session_id, self._testMethodName, status)
67+
68+
if __name__ == '__main__':
69+
unittest.main()
70+
```
71+
72+
For more information on running Selenium RC/WebDriver tests with Python, please see [Python WebDriver Examples](http://testingbot.com/support/getting-started/python.html)
3573

3674

3775
## More documentation

0 commit comments

Comments
 (0)