changes made with respect to the comments
parent
f600f2bc24
commit
8f9c34da3f
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
<component name="TestRunnerService">
|
||||||
|
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/SeleniumNeil.iml" filepath="$PROJECT_DIR$/.idea/SeleniumNeil.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,6 +10,9 @@ from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.wait import WebDriverWait
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
|
||||||
|
from conftest import url, driver, restore_database
|
||||||
|
|
||||||
|
|
||||||
def test_function_1(restore_database):
|
def test_function_1(restore_database):
|
||||||
assert restore_database is None
|
assert restore_database is None
|
||||||
@pytest.mark.skip(reason="function to be used in the test_scripts")
|
@pytest.mark.skip(reason="function to be used in the test_scripts")
|
||||||
|
@ -27,7 +30,7 @@ def createTA(driver, TA_name, emails, password):
|
||||||
|
|
||||||
def login_lecturer(drivers):
|
def login_lecturer(drivers):
|
||||||
# Open the website
|
# Open the website
|
||||||
drivers.get("http://localhost/LRR/")
|
drivers.get(url())
|
||||||
drivers.maximize_window()
|
drivers.maximize_window()
|
||||||
|
|
||||||
username_input = drivers.find_element('name', "user")
|
username_input = drivers.find_element('name', "user")
|
||||||
|
@ -49,8 +52,9 @@ def login_lecturer(drivers):
|
||||||
cte_instructor.click()
|
cte_instructor.click()
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
|
|
||||||
def test_createTA():
|
|
||||||
driver_open = webdriver.Chrome()
|
def test_createTA(url, driver, restore_database):
|
||||||
|
driver_open = driver();
|
||||||
driver_open.maximize_window()
|
driver_open.maximize_window()
|
||||||
login_lecturer(driver_open)
|
login_lecturer(driver_open)
|
||||||
try:
|
try:
|
||||||
|
@ -100,97 +104,3 @@ def test_createTA():
|
||||||
finally:
|
finally:
|
||||||
driver_open.quit()
|
driver_open.quit()
|
||||||
|
|
||||||
|
|
||||||
def test_generate_password():
|
|
||||||
driver_open = webdriver.Chrome()
|
|
||||||
login_lecturer(driver_open)
|
|
||||||
try:
|
|
||||||
fullname = "lanhuitest2"
|
|
||||||
email = "lanhuitest2@qq.com"
|
|
||||||
password = ""
|
|
||||||
createTA(driver_open, fullname, email,
|
|
||||||
password) # CREATE A TA WITH FULLNAME lanhuitest2 email lanhuitest2@qq.com password ""
|
|
||||||
|
|
||||||
get_output = WebDriverWait(driver_open, 15).until(
|
|
||||||
EC.element_to_be_clickable((By.ID, "tab_ins_accounts"))
|
|
||||||
)
|
|
||||||
get_output.click()
|
|
||||||
get_output_msg = driver_open.find_element(By.CLASS_NAME, "alert-warning")
|
|
||||||
txt_alert = get_output_msg.text
|
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
if txt_alert.find("TA user created successfully") == 0:
|
|
||||||
time.sleep(15)
|
|
||||||
email_pattern = r"Use email (\S+) as account name"
|
|
||||||
password_pattern = r" (\S+)\ as password."
|
|
||||||
email_match = re.search(email_pattern, txt_alert)
|
|
||||||
password_match = re.search(password_pattern, txt_alert)
|
|
||||||
if email_match and password_match:
|
|
||||||
# Extract email and password from the matches
|
|
||||||
email = email_match.group(1)
|
|
||||||
password = password_match.group(1)
|
|
||||||
logout_button = WebDriverWait(driver_open, 15).until(
|
|
||||||
EC.element_to_be_clickable(
|
|
||||||
(By.XPATH, "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]"))
|
|
||||||
)
|
|
||||||
logout_button.click()
|
|
||||||
time.sleep(15)
|
|
||||||
username_input = driver_open.find_element('name', "user")
|
|
||||||
password_input = driver_open.find_element('name', "password")
|
|
||||||
login_button = driver_open.find_element('id', "login_btn")
|
|
||||||
# login as the new TA
|
|
||||||
username_input.send_keys(email) # login with credentials of the created TA
|
|
||||||
password_input.send_keys(password)
|
|
||||||
# Click the login button
|
|
||||||
time.sleep(15)
|
|
||||||
|
|
||||||
login_button.click()
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
elif txt_alert.find("Email address ") == 0:
|
|
||||||
time.sleep(15)
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
||||||
else:
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
finally:
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
||||||
def test_existingTA():
|
|
||||||
driver_open = webdriver.Chrome()
|
|
||||||
login_lecturer(driver_open)
|
|
||||||
try:
|
|
||||||
# Use email nreyes@example.com as account name and new1452345678 as password.
|
|
||||||
fullname = "lanhuitest1"
|
|
||||||
email = "lanhuitest1@qq.com"
|
|
||||||
password = "new1452345678"
|
|
||||||
createTA(driver_open, fullname, email,
|
|
||||||
password) # CREATE A TA WITH FULLNAME lanhuitest1 email lanhuitest1@qq.com password new1452345678
|
|
||||||
|
|
||||||
get_output = WebDriverWait(driver_open, 10).until(
|
|
||||||
EC.element_to_be_clickable((By.ID, "tab_ins_accounts"))
|
|
||||||
)
|
|
||||||
get_output.click()
|
|
||||||
get_output_msg = driver_open.find_element(By.CLASS_NAME, "alert-warning")
|
|
||||||
txt_alert = get_output_msg.text
|
|
||||||
time.sleep(15)
|
|
||||||
|
|
||||||
if txt_alert.find("TA user created successfully") == 0:
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
|
|
||||||
elif txt_alert.find("Email address ") == 0:
|
|
||||||
time.sleep(15)
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
||||||
else:
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
finally:
|
|
||||||
driver_open.quit()
|
|
||||||
|
|
Loading…
Reference in New Issue