-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
56 lines (44 loc) · 1.44 KB
/
tests.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from time import sleep
from colorama import Fore
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
def login_test(driver):
sleep(4)
driver.find_element(By.ID, "navbarLogin").click()
sleep(5)
driver.find_element(By.ID, "userInput").send_keys("receptionuser")
driver.find_element(By.ID, "passwordInput").send_keys("admin")
sleep(5)
driver.find_element(By.CSS_SELECTOR, ".login_button").click()
try:
driver.find_element(By.ID, "navbarLogout")
print(Fore.GREEN + "Login system working succesfully")
except:
print(Fore.RED + "Login system failed")
def check_reception_view(driver):
try:
driver.find_element(By.ID, "navbarRecepcio")
print(Fore.GREEN + "Reception view working succesfully")
except:
print(Fore.RED + "Reception view failed")
def logout_test(driver):
driver.find_element(By.ID, "navbarLogout").click()
sleep(5)
try:
driver.find_element(By.ID, "navbarLogin")
print(Fore.GREEN + "Logout system working succesfully")
except:
print(Fore.RED + "Logout system failed")
def run_tests():
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://localhost:8000/")
login_test(driver)
check_reception_view(driver)
sleep(5)
logout_test(driver)
sleep(2)
driver.close()
if __name__ == '__main__':
run_tests()