Add a new regression test
parent
33f997412b
commit
a34ab61916
|
@ -285,7 +285,7 @@ CREATE TABLE `users_table` (
|
||||||
|
|
||||||
INSERT INTO `users_table` (`User_ID`, `Email`, `Password`, `HashPassword`, `Full_Name`, `UserType`, `Student_ID`, `Passport_Number`, `Status`) VALUES
|
INSERT INTO `users_table` (`User_ID`, `Email`, `Password`, `HashPassword`, `Full_Name`, `UserType`, `Student_ID`, `Passport_Number`, `Status`) VALUES
|
||||||
(3, 'admin@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Kamal', 'Admin', '0', NULL, 'Active'),
|
(3, 'admin@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Kamal', 'Admin', '0', NULL, 'Active'),
|
||||||
(8, 'lanhui@qq.com', '1234', '', 'Lanhui', 'Lecturer', NULL, '123', 'Active'),
|
(8, 'lanhui@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Lanhui', 'Lecturer', NULL, '123', 'Active'),
|
||||||
(9, 'mohamed@qq.com', '123', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'),
|
(9, 'mohamed@qq.com', '123', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'),
|
||||||
(10, 'mark@qq.com', '123', '', 'Mark ', 'TA', NULL, '123', 'Active'),
|
(10, 'mark@qq.com', '123', '', 'Mark ', 'TA', NULL, '123', 'Active'),
|
||||||
(11, 'john@qq.com', '123', '', 'John', 'TA', NULL, '123', 'Active'),
|
(11, 'john@qq.com', '123', '', 'John', 'TA', NULL, '123', 'Active'),
|
||||||
|
|
|
@ -31,3 +31,12 @@ def login(driver, url, username, password):
|
||||||
)
|
)
|
||||||
except (NoSuchElementException, UnexpectedAlertPresentException) as e:
|
except (NoSuchElementException, UnexpectedAlertPresentException) as e:
|
||||||
return f"Error: {str(e)}"
|
return f"Error: {str(e)}"
|
||||||
|
|
||||||
|
|
||||||
|
def logout(driver):
|
||||||
|
logout_button = WebDriverWait(driver, 10).until(
|
||||||
|
EC.element_to_be_clickable(
|
||||||
|
(By.XPATH, "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
logout_button.click()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from helper import login
|
from helper import login, logout
|
||||||
import time
|
import time
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.wait import WebDriverWait
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
|
@ -25,12 +25,7 @@ def test_admin_can_create_lecturer_account(driver, url, admin_username, admin_pa
|
||||||
button.click()
|
button.click()
|
||||||
|
|
||||||
# Log out Admin account
|
# Log out Admin account
|
||||||
logout_button = WebDriverWait(driver, 10).until(
|
logout(driver)
|
||||||
EC.element_to_be_clickable(
|
|
||||||
(By.XPATH, "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
logout_button.click()
|
|
||||||
|
|
||||||
# Log in Lecturer account
|
# Log in Lecturer account
|
||||||
login(driver, url, 'mrlan@qq.com', '123Abc!!')
|
login(driver, url, 'mrlan@qq.com', '123Abc!!')
|
||||||
|
@ -40,11 +35,30 @@ def test_admin_can_create_lecturer_account(driver, url, admin_username, admin_pa
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
||||||
|
def test_lecturer_can_create_course(driver, url, restore_database):
|
||||||
|
# Lecturer lanhui@qq.com logs in
|
||||||
|
driver.maximize_window()
|
||||||
|
login(driver, url, 'lanhui@qq.com', '123')
|
||||||
|
|
||||||
def test_lecturer_can_create_course():
|
|
||||||
# Lecturer mrlan@qq.com logs in
|
|
||||||
# Create a course called CSC1001 Advanced Software Engineering, 2024
|
# Create a course called CSC1001 Advanced Software Engineering, 2024
|
||||||
assert True
|
elem = driver.find_element(By.NAME, 'name')
|
||||||
|
elem.send_keys('Advanced Software Engineering')
|
||||||
|
elem = driver.find_element(By.NAME, 'code')
|
||||||
|
elem.send_keys('CSC1001')
|
||||||
|
elem = driver.find_element(By.NAME, 'academic')
|
||||||
|
elem.send_keys('2004')
|
||||||
|
elem = driver.find_element(By.NAME, 'faculty')
|
||||||
|
elem.send_keys('School of Computer Science and Technology')
|
||||||
|
elem = driver.find_element(By.CLASS_NAME, 'btn-primary')
|
||||||
|
elem.click()
|
||||||
|
elems = driver.find_elements(By.CLASS_NAME, 'btn-default')
|
||||||
|
last_elem = elems[-1]
|
||||||
|
assert 'Advanced Software Engineering' in last_elem.text
|
||||||
|
assert '(CSC1001)' in last_elem.text
|
||||||
|
|
||||||
|
# Logout
|
||||||
|
logout(driver)
|
||||||
|
driver.quit()
|
||||||
|
|
||||||
|
|
||||||
def test_lecturer_can_post_assignment():
|
def test_lecturer_can_post_assignment():
|
||||||
|
|
Loading…
Reference in New Issue