daily pastebin goal
4%
SHARE
TWEET

Yuce Tekol

a guest Oct 9th, 2009 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import unittest
  3. from selenium import selenium
  4.  
  5.  
  6. # Select Firefox as the browser (Note that this is not Chrome browser)
  7. BROWSER = '*chrome'
  8. SITE_URL = 'http://en.wikipedia.org'
  9.  
  10. class WikipediaSeleniumTest(unittest.TestCase):
  11.     def setUp(self):
  12.         self.sel = selenium('localhost', 4444, BROWSER, SITE_URL)
  13.         self.sel.start()
  14.  
  15.     def test_wikipedia(self):
  16.         sel = self.sel
  17.         sel.open('/')
  18.  
  19.         # Go to selenium page
  20.         sel.type('id=searchInput', 'selenium')
  21.         sel.click('id=searchGoButton')
  22.         sel.wait_for_page_to_load(30000)
  23.         # assure we are on selenium page
  24.         assert sel.get_title().startswith('Selenium'), \
  25.             'Selenium page not reached'
  26.  
  27.         # Wikipedia displays selenium element page, let's visit the
  28.         # software one
  29.         sel.click('link=Selenium (software)')
  30.         sel.wait_for_page_to_load(30000)
  31.         assert sel.get_title().startswith('Selenium (software)'), \
  32.             'Selenium (software) page not reached'
  33.  
  34.         # wait a bit so we can see the last page
  35.         time.sleep(5)
  36.  
  37.     def tearDown(self):
  38.         self.sel.stop()
  39.  
  40. if __name__ == '__main__':
  41.     unittest.main()
RAW Paste Data
Top