Advertisement
PandaAcademy

Selenium - python.org

May 2nd, 2022
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import unittest
  2. from selenium import webdriver
  3. from selenium.webdriver.common.keys import Keys
  4. from os import environ
  5. from selenium.webdriver.common.by import By
  6.  
  7. application_URL = environ.get('APPLICATION_URL', 'http://192.168.44.44:5000/')
  8. selenium_URL = environ.get('SELENIUM_URL', 'http://192.168.44.44:4444/wd/hub')
  9.  
  10.  
  11. class PythonOrgSearch(unittest.TestCase):
  12.  
  13.     def setUp(self):
  14.         self.driver = webdriver.Firefox()
  15.         # self.driver = webdriver.Remote(
  16.         #     command_executor=selenium_URL,
  17.         #     options=webdriver.FirefoxOptions())
  18.  
  19.     def test_search_in_python_org(self):
  20.         driver = self.driver
  21.         driver.implicitly_wait(5)
  22.         driver.get("http://www.python.org")
  23.         self.assertIn("Python", driver.title)
  24.         elem = driver.find_element(By.NAME, "q")
  25.         elem.send_keys("pycon")
  26.         elem.send_keys(Keys.RETURN)
  27.         self.assertNotIn("No results found.", driver.page_source)
  28.         driver.quit()
  29.  
  30.  
  31. if __name__ == "__main__":
  32.     unittest.main()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement