Skip to content

Instantly share code, notes, and snippets.

@santiycr
Created November 30, 2010 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santiycr/721373 to your computer and use it in GitHub Desktop.
Save santiycr/721373 to your computer and use it in GitHub Desktop.
Sauce OnDemand test using the new setContext extension
from selenium import selenium
import unittest, time
class sauce(unittest.TestCase):
def setUp(self):
self.browser = selenium(
'ondemand.saucelabs.com',
80,
"""{\
"username": "<username>",\
"access-key": "<access key>",\
"os": "Windows 2003",\
"browser": "firefox",\
"browser-version": "3.",\
"user-extensions-url": "http://saucelabs.com/ext/setContext.js",\
"name": "Telling stories at Sauce"\
}""",
'http://saucelabs.com')
self.browser.start()
self.browser.set_timeout(90000)
def test_sauce(self):
browser = self.browser
browser.set_context("When I go to Sauce's Website...")
browser.open("/")
browser.set_context("the title should include \"<b>Sauce Labs</b>\".")
assert "Sauce Labs" in browser.get_title()
time.sleep(2)
browser.set_context("If I login as the <i>demo</i> account...")
time.sleep(2)
browser.open("/login")
assert "Login" in browser.get_title()
browser.type("username", "demo")
browser.type("password", "changed_already:P")
browser.click("submit")
browser.wait_for_page_to_load(90000)
browser.set_context("I should see I have remaining minutes in my account...")
assert int(browser.get_text("remaining-minutes")) > 0
time.sleep(3)
browser.set_context("everything is ok so I'm happy. Time to logout and leave.")
browser.click("link=Logout")
browser.wait_for_page_to_load(90000)
browser.set_context("Mission Accomplished!")
time.sleep(3)
def tearDown(self):
self.browser.stop()
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment