Advertisement
Guest User

Web Driver Python

a guest
Jul 26th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import unittest
  2. from selenium.webdriver.support import expected_conditions
  3. from selenium import webdriver
  4. from selenium.webdriver.support.ui import WebDriverWait
  5.  
  6.  
  7. class GoogleSearch(unittest.TestCase):
  8.     def setUp(self):
  9.         self.driver = webdriver.Firefox()
  10.         self.driver.implicitly_wait(30)
  11.         self.base_url = "https://www.google.com/"
  12.  
  13.     def test_google_search(self):
  14.         driver = self.driver
  15.         driver.get(self.base_url)
  16.  
  17.         element = driver.find_element_by_idname("q")
  18.         element.clear()
  19.         element.send_keys("Selenium testing tools cookbook")
  20.         element.submit()
  21.  
  22.         WebDriverWait(driver, 30)\
  23.             .until(expected_conditions.title_contains("Selenium testing tools cookbook"))
  24.         self.assertEqual(driver.title, "Selenium testing tools cookbook - Google Search")
  25.  
  26.     def tearDown(self):
  27.         self.driver.quit()
  28.  
  29. if __name__ == "__main__":
  30.     unittest.main(verbosity=2, warnings="ignore")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement