-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_authentication_unittest.py
35 lines (24 loc) · 1.18 KB
/
form_authentication_unittest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest
import time
class TestFormAuthentication(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.get('https://the-internet.herokuapp.com')
self.driver.set_window_size(1000, 750)
self.driver.implicitly_wait(10)
def tearDown(self):
self.driver.quit()
def test_form_authentication_login(self):
self.driver.find_element(By.LINK_TEXT, "Form Authentication").click()
self.driver.find_element(By.ID, "username").send_keys("tomsmith")
self.driver.find_element(By.ID, "password").send_keys("SuperSecretPassword!")
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR, "#login > button").click()
login_message = self.driver.find_element(By.XPATH, '//*[@id="content"]/div/h4')
self.assertEqual(login_message.text, "Welcome to the Secure Area. When you are done click logout below.")
self.driver.find_element(By.XPATH, '//*[@id="content"]/div/a').click()
time.sleep(2)
if __name__ == "__main__":
unittest.main()