The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Sell
By Guest on 25th July 2018 04:49:18 PM | Syntax: PYTHON | Views: 1



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. import unittest
  2. from selenium import webdriver
  3. from selenium.webdriver.common.keys import Keys
  4.  
  5. class SearchText(unittest.TestCase):
  6.    
  7.  
  8.  
  9.     def setUp(self):
  10.         """Creating the driver window"""
  11.         self.driver = webdriver.Chrome()
  12.         self.driver.implicitly_wait(1)
  13.         self.driver.maximize_window()
  14.         self.driver.get("http://www.google.com")
  15.  
  16.     def test_search_by_text(self):
  17.         """Get the search box"""
  18.         self.search_field = self.driver.find_element_by_id("lst-ib")
  19. #        user_inp = input("What do you wanna search for? ")
  20.         self.search_field.send_keys("Just Search")        
  21.         self.search_field.submit()
  22.         self.search_field.send_keys(Keys.CONTROL+"t")
  23.         try:
  24.             lists = self.driver.find_elements_by_class_name("g")
  25.             no=len(lists)
  26.             self.assertEqual(10, len(lists))
  27.         except AssertionError as e:
  28.             print("Error is: {}".format(e))
  29.  
  30.     def tearDown(self):
  31.         self.driver.quit()
  32.  
  33. st = SearchText()
  34.  
  35. st.setUp()
  36. st.test_search_by_text()



  • Recent Pastes

Advertise here

Advertise here