-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathsauce_ondemand_test.py
66 lines (56 loc) · 2.17 KB
/
sauce_ondemand_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from selenium import webdriver
import unittest, time, re
import os
import json
from ParseSauceURL import *
from SeleniumFactory import *
"""
"""
class testSauceWrappers(unittest.TestCase):
username = "rossco_9_9"
access_key = "blah-blah-blah"
def setUp(self):
self.url = "sauce-ondemand:?username=%s&access-key=%s&job-name=simple test&os=Linux&browser=firefox&browser-version=7&firefox-profile-url=&idle-timeout=90&user-extensions-url=" % (self.username, self.access_key)
os.environ["SELENIUM_DRIVER"] = self.url
os.environ["SELENIUM_PORT"] = "80"
os.environ["SELENIUM_HOST"] = "ondemand.saucelabs.com"
os.environ["SELENIUM_STARTING_URL"]= "http://www.amazon.com"
def retrieve_job_details(self, browser):
sauceRest = SauceRest(self.username, self.access_key)
result = sauceRest.get(browser.id())
data = json.loads(result)
return data
def test_webdriver_success(self):
browser = SeleniumFactory().createWebDriver()
browser.get("http://amazon.com")
assert "Amazon.com" in browser.title
browser.job_passed()
data = self.retrieve_job_details(browser)
assert data['passed']
browser.quit()
def test_webdriver_failed(self):
browser = SeleniumFactory().createWebDriver()
browser.get("http://amazon.com")
assert "Amazon.com" in browser.title
browser.job_failed()
data = self.retrieve_job_details(browser)
assert not data['passed']
browser.quit()
def test_selenium_success(self):
browser = SeleniumFactory().create()
browser.open("http://www.amazon.com")
assert "Amazon.com" in browser.get_title()
browser.job_passed()
data = self.retrieve_job_details(browser)
assert data['passed']
browser.stop()
def test_selenium_failed(self):
browser = SeleniumFactory().create()
browser.open("http://www.amazon.com")
assert "Amazon.com" in browser.get_title()
browser.job_failed()
data = self.retrieve_job_details(browser)
assert not data['passed']
browser.stop()
if __name__ == "__main__":
unittest.main()