Advertisement
PandaAcademy

frontendTest.py

May 28th, 2022 (edited)
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 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 AppTest(unittest.TestCase):
  12.     def setUp(self):
  13.         # self.driver = webdriver.Firefox()
  14.         self.driver = webdriver.Remote(
  15.             command_executor=selenium_URL,
  16.             options=webdriver.FirefoxOptions())
  17.  
  18.     def test_our_app(self):
  19.         driver = self.driver
  20.         driver.set_page_load_timeout(5)
  21.         driver.set_script_timeout(5)
  22.         driver.get(application_URL)
  23.         elem = driver.find_element(By.NAME, "name")
  24.         elem.send_keys("luka")
  25.         elem = driver.find_element(By.NAME, "animal")
  26.         elem.send_keys("dog")
  27.         elem.send_keys(Keys.RETURN)
  28.         self.assertNotIn("No results found.", driver.page_source)
  29.         driver.quit()
  30.  
  31. if __name__ == "__main__":
  32.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement