Skip to content

Instantly share code, notes, and snippets.

@erikkaplun
Created January 26, 2011 13:03
Show Gist options
  • Save erikkaplun/796654 to your computer and use it in GitHub Desktop.
Save erikkaplun/796654 to your computer and use it in GitHub Desktop.
Seleniumi test case'id
import re
import time
import unittest
import selenium
class TestCase1(unittest.TestCase):
def setUp(self):
self.verification_errors = []
self.selenium = selenium.selenium("localhost", 4444, "*chrome",
"http://www.titanpoker.com/")
self.selenium.start()
def test_case_1(self):
sel = self.selenium
sel.open("/")
sel.click("//li[4]/ul/li[6]/a/span")
sel.wait_for_page_to_load("30000")
try:
self.failUnless(sel.is_text_present("Fort Knox Jackpot"))
except AssertionError, e:
self.verification_errors.append(str(e))
sel.open("http://www.ipoker.com/xml_feed2/xml/feed.xml")
# sel.assert_text_present_x_m_l("280000")
# sel.verify_text_present_x_m_l("280000")
sel.open("/")
sel.click("//li[4]/ul/li[6]/a/span")
sel.wait_for_page_to_load("30000")
try:
text = "Click here for full terms and conditions."
self.failUnless(sel.is_text_present(text))
except AssertionError, e:
self.verification_errors.append(str(e))
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verification_errors)
if __name__ == "__main__":
unittest.main()
import re
import time
import unittest
import selenium
# We will retrieve these from the command line arguments.
PAGE_URL = None
TOURNAMENT_NAME = None
class Untitled(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", PAGE_URL)
self.selenium.start()
def test_untitled(self):
if TOURNAMENT_NAME is None:
raise RuntimeError('Tournament name must be specified')
JACKPOT_NAME = TOURNAMENT_NAME + " Jackpot"
sel = self.selenium
sel.open("/")
sel.click("//ul[2]/li[4]/a/span")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present(JACKPOT_NAME))
try: self.failUnless(sel.is_text_present(JACKPOT_NAME))
except AssertionError, e: self.verificationErrors.append(str(e))
sel.click("//a[contains(text(),'%s')]" % JACKPOT_NAME)
sel.wait_for_page_to_load("30000")
sel.click("link=To check current size of the progressive jackpot, please click here.")
# sel.assert_text_present_x_m_l(TOURNAMENT_NAME, "<amount></amount>")
# sel.verify_text_present_x_m_l(TOURNAMENT_NAME)
sel.open("/")
sel.click("//ul[2]/li[4]/a/span")
sel.wait_for_page_to_load("30000")
sel.click("//a[contains(text(),'%s')]" % JACKPOT_NAME)
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Click here for full terms and conditions."))
try: self.failUnless(sel.is_text_present("Click here for full terms and conditions."))
except AssertionError, e: self.verificationErrors.append(str(e))
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
import sys
script_name = sys.argv[0]
parameters = sys.argv[1:]
if len(parameters) != 2:
print('Usage:\n'
' %s page_url tournament_name\n')
exit(1); # 1 signifies an error.
PAGE_URL, TOURNAMENT_NAME = parameters
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment