@@ -90,11 +90,11 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
' . $_SESSION['info_Admin_Users'] . '
';
+ echo '
' . $_SESSION['info_Admin_Users'] . '
';
$_SESSION['info_Admin_Users'] = null;
}
if (isset($_SESSION['info_Admin_Users'])) {
- echo '
' . $_SESSION['info_Admin_Users'] . '
';
+ echo '
' . $_SESSION['info_Admin_Users'] . '
';
$_SESSION['info_Admin_Users'] = null;
}
?>
From f29f2d5212cd12155a9c05535c707509f561d5e3 Mon Sep 17 00:00:00 2001
From: newtechAI
Date: Tue, 19 Dec 2023 15:03:57 +0100
Subject: [PATCH 14/20] 3 test files has been added to the project this files
can be found under the folder test and subfolder SeleniumNeil a demonstation
video is found in this link
https://cloud.zjnu.edu.cn/share/6c07a0f2ed1304743078234ea1
---
test/SeleniumNeil/TEST_CREATED_TA.py | 27 +++++++
test/SeleniumNeil/TEST_CREATING_TA.py | 71 +++++++++++++++++++
test/SeleniumNeil/TEST_CREATING_TA.txt | 2 +
test/SeleniumNeil/TEST_GENERATING_PASSWORD.py | 68 ++++++++++++++++++
.../SeleniumNeil/TEST_GENERATING_PASSWORD.txt | 3 +
5 files changed, 171 insertions(+)
create mode 100644 test/SeleniumNeil/TEST_CREATED_TA.py
create mode 100644 test/SeleniumNeil/TEST_CREATING_TA.py
create mode 100644 test/SeleniumNeil/TEST_CREATING_TA.txt
create mode 100644 test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
create mode 100644 test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
diff --git a/test/SeleniumNeil/TEST_CREATED_TA.py b/test/SeleniumNeil/TEST_CREATED_TA.py
new file mode 100644
index 0000000..0538b15
--- /dev/null
+++ b/test/SeleniumNeil/TEST_CREATED_TA.py
@@ -0,0 +1,27 @@
+import time
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+
+driver_open = webdriver.Chrome()
+
+# Open the website
+driver_open.get("http://localhost/lrr/")
+try:
+ 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("lanhuitest@test.com") # login with credentials of the created TA
+ password_input.send_keys("lanhui12345678")
+ # Click the login button
+ login_button.click()
+ my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
+
+ print(" WELCOME TA YOU ARE IN")
+ time.sleep(20)
+
+finally:
+ driver_open.quit()
\ No newline at end of file
diff --git a/test/SeleniumNeil/TEST_CREATING_TA.py b/test/SeleniumNeil/TEST_CREATING_TA.py
new file mode 100644
index 0000000..dc51a04
--- /dev/null
+++ b/test/SeleniumNeil/TEST_CREATING_TA.py
@@ -0,0 +1,71 @@
+import time
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.wait import WebDriverWait
+from selenium.webdriver.support import expected_conditions as EC
+
+
+driver_open = webdriver.Chrome()
+
+# Open the website
+driver_open.get("http://localhost/lrr/")
+
+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 a TA
+username_input.send_keys("lanhui@qq.com")
+password_input.send_keys("nil1234H@")
+# Click the login button
+login_button.click()
+admin_tab = driver_open.find_element('id', 'admin_tab')
+admin_tab.click()
+print("login sucessfully")
+cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
+cte_instructor.click()
+print(" everything is ok here ")
+t = time.localtime()
+current_time = time.strftime("%H:%M:%S", t)
+time.sleep(25)
+def createTA(driver, TA_name, emails, password):
+ full_name = driver.find_element('name', 'fullname')
+ full_name.send_keys(TA_name)
+ email= driver.find_element('name', 'email')
+ email.send_keys(emails)
+ pas=driver.find_element('name', 'password')
+ pas.send_keys(password)
+ usr_type=driver.find_element('name', 'type')
+ usr_type.click()
+ click_create =driver.find_element('name', 'create_btn')
+ click_create.click()
+
+
+try:
+ createTA(driver_open,"lanhuitest","lanhuitest@test.com","lanhui12345678") # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
+
+ get_output = WebDriverWait(driver_open, 25).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
+ print(f" alert message is : {txt_alert}")
+
+ try:
+ with open('TEST_CREATING_TA.txt', 'a') as test_output:
+ test_output.write(f"\n {current_time} check this message : {txt_alert}")
+ except Exception as e:
+ print(f"unexpected error: {e}")
+
+ time.sleep(10)
+
+finally:
+ driver_open.quit()
+
+
+
diff --git a/test/SeleniumNeil/TEST_CREATING_TA.txt b/test/SeleniumNeil/TEST_CREATING_TA.txt
new file mode 100644
index 0000000..127c723
--- /dev/null
+++ b/test/SeleniumNeil/TEST_CREATING_TA.txt
@@ -0,0 +1,2 @@
+
+ 14:27:01 check this message : TA user created successfully. Use email lanhuitest@test.com as account name and lanhui12345678 as password.
\ No newline at end of file
diff --git a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
new file mode 100644
index 0000000..09e6514
--- /dev/null
+++ b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
@@ -0,0 +1,68 @@
+import time
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.wait import WebDriverWait
+from selenium.webdriver.support import expected_conditions as EC
+
+
+driver_open = webdriver.Chrome()
+
+# Open the website
+driver_open.get("http://localhost/lrr/")
+
+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 a TA
+username_input.send_keys("lanhui@qq.com")
+password_input.send_keys("nil1234H@")
+# Click the login button
+login_button.click()
+admin_tab = driver_open.find_element('id', 'admin_tab')
+admin_tab.click()
+print("login sucessfully")
+cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
+cte_instructor.click()
+print(" everything is ok here ")
+t = time.localtime()
+current_time = time.strftime("%H:%M:%S", t)
+time.sleep(25)
+def createTA(driver, TA_name, emails, password):
+ full_name = driver.find_element('name', 'fullname')
+ full_name.send_keys(TA_name)
+ email= driver.find_element('name', 'email')
+ email.send_keys(emails)
+ pas=driver.find_element('name', 'password')
+ pas.send_keys(password)
+ usr_type=driver.find_element('name', 'type')
+ usr_type.click()
+ click_create =driver.find_element('name', 'create_btn')
+ click_create.click()
+
+
+try:
+ createTA(driver_open,"testneil","test@test.com","") # create a TA with fullname testneil email test@test.com password empty to see if it generates a password.
+ print("Test case to check the generated password")
+ get_output = WebDriverWait(driver_open, 25).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
+ print(f" alert message is : {txt_alert}")
+
+ try:
+ with open('TEST_GENERATING_PASSWORD.txt', 'a') as test_output:
+ test_output.write(f"\n {current_time} check this message: {txt_alert}")
+ except Exception as e:
+ print(f"unexpected error: {e}")
+
+ time.sleep(20)
+
+finally:
+ driver_open.quit()
diff --git a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
new file mode 100644
index 0000000..06d86bb
--- /dev/null
+++ b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
@@ -0,0 +1,3 @@
+
+ 14:23:33 check this message: TA user created successfully. Use email test@test.com as account name and msevSHBV)BXk as password.
+ 14:25:35 check this message: Email address : test@test.com is already in use.
\ No newline at end of file
From 5a82c9130497c441e3f4e69ea3d2afc4cf7639ff Mon Sep 17 00:00:00 2001
From: Ayoub Rbahi
Date: Wed, 20 Dec 2023 03:52:29 +0800
Subject: [PATCH 15/20] Fix Bug 557
---
Script.php | 79 +++++++++++++++++++++++++++---------------------------
1 file changed, 39 insertions(+), 40 deletions(-)
diff --git a/Script.php b/Script.php
index c0bfd7e..be77f28 100644
--- a/Script.php
+++ b/Script.php
@@ -36,6 +36,45 @@ function is_valid_student_number($student_id)
// ############################### SIGN UP ##################################
if (!empty($_POST["form_signup"])) {
$student_id = trim(mysqli_real_escape_string($con, $_POST["user_student_id"]));
+ $email = mysqli_real_escape_string($con, $_POST["email"]);
+ $password = mysqli_real_escape_string($con, $_POST["password"]);
+ $confirmpassword = mysqli_real_escape_string($con, $_POST["confirmpassword"]);
+
+ $upperLetter = preg_match('@[A-Z]@', $password);
+ $smallLetter = preg_match('@[a-z]@', $password);
+ $containsDigit = preg_match('@[0-9]@', $password);
+ $containsSpecial = preg_match('@[^\w]@', $password);
+ $containsAll = $upperLetter && $smallLetter && $containsDigit && $containsSpecial;
+
+ // check for strong password
+ if (!$containsAll) {
+ $_SESSION['info_signup'] = "Password must have at least characters that include lowercase letters, uppercase letters, numbers and special characters (e.g., !?.,*^).";
+ header("Location: signup.php");
+ return;
+ }
+
+ // Check confirmed password
+ if (strcasecmp($password, $confirmpassword) != 0) {
+ $_SESSION['info_signup'] = "Password confirmation failed.";
+ header("Location: signup.php");
+ return;
+ }
+
+ // validate email
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ $_SESSION['info_signup'] = "Invalid email address.";
+ header("Location: signup.php");
+ return;
+ }
+
+ // check if email is taken
+ $result = mysqli_query($con, "SELECT * FROM users_table WHERE email='$email'");
+ if (mysqli_num_rows($result) != 0) {
+ $_SESSION["info_signup"] = "Email address " . $email . " is already in use.";
+ $_SESSION['user_fullname'] = null;
+ header("Location: signup.php");
+ return;
+ }
// validate student number
if (!is_valid_student_number($student_id)) {
@@ -67,51 +106,11 @@ if (!empty($_POST["form_signup"])) {
if (!empty($_POST["form_signup"])) {
$fullname = mysqli_real_escape_string($con, $_POST["fullname"]);
$student_id = mysqli_real_escape_string($con, $_POST["user_student_id"]);
- $email = mysqli_real_escape_string($con, $_POST["email"]);
- $password = mysqli_real_escape_string($con, $_POST["password"]);
- $confirmpassword = mysqli_real_escape_string($con, $_POST["confirmpassword"]);
$_SESSION['user_fullname'] = $fullname;
$_SESSION['user_type'] = "Student";
$_SESSION['user_email'] = $email;
$_SESSION['user_student_id'] = $student_id;
- // check confirmed password
- if (strcasecmp($password, $confirmpassword) != 0) {
- $_SESSION['info_signup'] = "Password confirmation failed.";
- $_SESSION['user_fullname'] = null; // such that Header.php do not show the header information.
- header("Location: signup.php");
- return;
- }
-
- // validate email
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $_SESSION['info_signup'] = "Invalid email address.";
- header("Location: signup.php");
- return;
- }
-
- $upperLetter = preg_match('@[A-Z]@', $password);
- $smallLetter = preg_match('@[a-z]@', $password);
- $containsDigit = preg_match('@[0-9]@', $password);
- $containsSpecial = preg_match('@[^\w]@', $password);
- $containsAll = $upperLetter && $smallLetter && $containsDigit && $containsSpecial;
-
- // check for strong password
- if (!$containsAll) {
- $_SESSION['info_signup'] = "Password must have at least characters that include lowercase letters, uppercase letters, numbers and special characters (e.g., !?.,*^).";
- header("Location: signup.php");
- return;
- }
-
- // check if email is taken
- $result = mysqli_query($con, "SELECT * FROM users_table WHERE email='$email'");
- if (mysqli_num_rows($result) != 0) {
- $_SESSION["info_signup"] = "Email address " . $email . " is already in use.";
- $_SESSION['user_fullname'] = null;
- header("Location: signup.php");
- return;
- }
-
// apply password_hash()
$password_hash = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO `users_table`(`Email`, `Password`, `Full_Name`, `UserType`, `Student_ID`) VALUES "
From f3f7e0ccfd4804b39df4c64c2c3bae49ee399fda Mon Sep 17 00:00:00 2001
From: newtechAI
Date: Fri, 22 Dec 2023 14:59:17 +0100
Subject: [PATCH 16/20] Update test case script with improvements
- Introduce pytest framework to consolidate test cases into a single file.
- Directly test the login functionality for newly created Teaching Assistants (TA's).
---
test/SeleniumNeil/TEST_CREATED_TA.py | 27 ---
test/SeleniumNeil/TEST_CREATING_TA.py | 71 ------
test/SeleniumNeil/TEST_CREATING_TA.txt | 2 -
test/SeleniumNeil/TEST_GENERATING_PASSWORD.py | 68 ------
.../SeleniumNeil/TEST_GENERATING_PASSWORD.txt | 3 -
test/SeleniumNeil/test_cases.py | 206 ++++++++++++++++++
6 files changed, 206 insertions(+), 171 deletions(-)
delete mode 100644 test/SeleniumNeil/TEST_CREATED_TA.py
delete mode 100644 test/SeleniumNeil/TEST_CREATING_TA.py
delete mode 100644 test/SeleniumNeil/TEST_CREATING_TA.txt
delete mode 100644 test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
delete mode 100644 test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
create mode 100644 test/SeleniumNeil/test_cases.py
diff --git a/test/SeleniumNeil/TEST_CREATED_TA.py b/test/SeleniumNeil/TEST_CREATED_TA.py
deleted file mode 100644
index 0538b15..0000000
--- a/test/SeleniumNeil/TEST_CREATED_TA.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import time
-
-from selenium import webdriver
-from selenium.webdriver.common.by import By
-
-driver_open = webdriver.Chrome()
-
-# Open the website
-driver_open.get("http://localhost/lrr/")
-try:
- 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("lanhuitest@test.com") # login with credentials of the created TA
- password_input.send_keys("lanhui12345678")
- # Click the login button
- login_button.click()
- my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
-
- print(" WELCOME TA YOU ARE IN")
- time.sleep(20)
-
-finally:
- driver_open.quit()
\ No newline at end of file
diff --git a/test/SeleniumNeil/TEST_CREATING_TA.py b/test/SeleniumNeil/TEST_CREATING_TA.py
deleted file mode 100644
index dc51a04..0000000
--- a/test/SeleniumNeil/TEST_CREATING_TA.py
+++ /dev/null
@@ -1,71 +0,0 @@
-import time
-
-from selenium import webdriver
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.wait import WebDriverWait
-from selenium.webdriver.support import expected_conditions as EC
-
-
-driver_open = webdriver.Chrome()
-
-# Open the website
-driver_open.get("http://localhost/lrr/")
-
-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 a TA
-username_input.send_keys("lanhui@qq.com")
-password_input.send_keys("nil1234H@")
-# Click the login button
-login_button.click()
-admin_tab = driver_open.find_element('id', 'admin_tab')
-admin_tab.click()
-print("login sucessfully")
-cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
-cte_instructor.click()
-print(" everything is ok here ")
-t = time.localtime()
-current_time = time.strftime("%H:%M:%S", t)
-time.sleep(25)
-def createTA(driver, TA_name, emails, password):
- full_name = driver.find_element('name', 'fullname')
- full_name.send_keys(TA_name)
- email= driver.find_element('name', 'email')
- email.send_keys(emails)
- pas=driver.find_element('name', 'password')
- pas.send_keys(password)
- usr_type=driver.find_element('name', 'type')
- usr_type.click()
- click_create =driver.find_element('name', 'create_btn')
- click_create.click()
-
-
-try:
- createTA(driver_open,"lanhuitest","lanhuitest@test.com","lanhui12345678") # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
-
- get_output = WebDriverWait(driver_open, 25).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
- print(f" alert message is : {txt_alert}")
-
- try:
- with open('TEST_CREATING_TA.txt', 'a') as test_output:
- test_output.write(f"\n {current_time} check this message : {txt_alert}")
- except Exception as e:
- print(f"unexpected error: {e}")
-
- time.sleep(10)
-
-finally:
- driver_open.quit()
-
-
-
diff --git a/test/SeleniumNeil/TEST_CREATING_TA.txt b/test/SeleniumNeil/TEST_CREATING_TA.txt
deleted file mode 100644
index 127c723..0000000
--- a/test/SeleniumNeil/TEST_CREATING_TA.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-
- 14:27:01 check this message : TA user created successfully. Use email lanhuitest@test.com as account name and lanhui12345678 as password.
\ No newline at end of file
diff --git a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
deleted file mode 100644
index 09e6514..0000000
--- a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.py
+++ /dev/null
@@ -1,68 +0,0 @@
-import time
-
-from selenium import webdriver
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.wait import WebDriverWait
-from selenium.webdriver.support import expected_conditions as EC
-
-
-driver_open = webdriver.Chrome()
-
-# Open the website
-driver_open.get("http://localhost/lrr/")
-
-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 a TA
-username_input.send_keys("lanhui@qq.com")
-password_input.send_keys("nil1234H@")
-# Click the login button
-login_button.click()
-admin_tab = driver_open.find_element('id', 'admin_tab')
-admin_tab.click()
-print("login sucessfully")
-cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
-cte_instructor.click()
-print(" everything is ok here ")
-t = time.localtime()
-current_time = time.strftime("%H:%M:%S", t)
-time.sleep(25)
-def createTA(driver, TA_name, emails, password):
- full_name = driver.find_element('name', 'fullname')
- full_name.send_keys(TA_name)
- email= driver.find_element('name', 'email')
- email.send_keys(emails)
- pas=driver.find_element('name', 'password')
- pas.send_keys(password)
- usr_type=driver.find_element('name', 'type')
- usr_type.click()
- click_create =driver.find_element('name', 'create_btn')
- click_create.click()
-
-
-try:
- createTA(driver_open,"testneil","test@test.com","") # create a TA with fullname testneil email test@test.com password empty to see if it generates a password.
- print("Test case to check the generated password")
- get_output = WebDriverWait(driver_open, 25).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
- print(f" alert message is : {txt_alert}")
-
- try:
- with open('TEST_GENERATING_PASSWORD.txt', 'a') as test_output:
- test_output.write(f"\n {current_time} check this message: {txt_alert}")
- except Exception as e:
- print(f"unexpected error: {e}")
-
- time.sleep(20)
-
-finally:
- driver_open.quit()
diff --git a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt b/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
deleted file mode 100644
index 06d86bb..0000000
--- a/test/SeleniumNeil/TEST_GENERATING_PASSWORD.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-
- 14:23:33 check this message: TA user created successfully. Use email test@test.com as account name and msevSHBV)BXk as password.
- 14:25:35 check this message: Email address : test@test.com is already in use.
\ No newline at end of file
diff --git a/test/SeleniumNeil/test_cases.py b/test/SeleniumNeil/test_cases.py
new file mode 100644
index 0000000..88eb588
--- /dev/null
+++ b/test/SeleniumNeil/test_cases.py
@@ -0,0 +1,206 @@
+import re
+import time
+import pytest
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.wait import WebDriverWait
+from selenium.webdriver.support import expected_conditions as EC
+
+@pytest.mark.generate_password_1
+def test_createTA():
+
+ driver_open = webdriver.Chrome()
+ driver_open.maximize_window()
+
+ # Open the website
+ driver_open.get("http://localhost/lrr/")
+
+ 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 a TA
+ username_input.send_keys("lanhui@qq.com")
+ password_input.send_keys("nil1234H@")
+ # Click the login button
+ login_button.click()
+ admin_tab = driver_open.find_element('id', 'admin_tab')
+ admin_tab.click()
+ print("login sucessfully")
+ cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
+ cte_instructor.click()
+ print(" everything is ok here ")
+ t = time.localtime()
+ current_time = time.strftime("%H:%M:%S", t)
+ time.sleep(25)
+ def createTA(driver, TA_name, emails, password):
+ full_name = driver.find_element('name', 'fullname')
+ full_name.send_keys(TA_name)
+ email= driver.find_element('name', 'email')
+ email.send_keys(emails)
+ pas=driver.find_element('name', 'password')
+ pas.send_keys(password)
+ usr_type=driver.find_element('name', 'type')
+ usr_type.click()
+ click_create =driver.find_element('name', 'create_btn')
+ click_create.click()
+
+
+ try:
+ fullname = "testname"
+ email = "labtest0@fgy.com"
+ password = "newpasasr12345678"
+ createTA(driver_open,fullname,email,password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
+
+ 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:
+
+ logout_button = driver_open.find_element(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(20)
+
+ login_button.click()
+
+ time.sleep(15)
+ my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
+ email_pattern = r"Use email (\S+) as account name"
+ password_pattern = r"as password (\S+)\."
+ email_match = re.search(email_pattern, txt_alert)
+ password_match = re.search(password_pattern, txt_alert)
+ print(f"Email: {email}")
+ print(f"Password: {password}")
+ print(" WELCOME TA YOU ARE IN")
+
+ elif txt_alert.find("Email address ")==0:
+ print(" EMAIL ALREADY EXIST ")
+ else:
+ driver_open.quit()
+ try:
+ with open('TEST_CREATING_TA.txt', 'a') as test_output:
+ test_output.write(f"\n {current_time} check this message : {txt_alert}")
+ except Exception as e:
+ print(f"unexpected error: {e}")
+
+ time.sleep(10)
+
+ finally:
+ driver_open.quit()
+@pytest.mark.generate_password_2()
+def test_generate_password():
+ driver_open = webdriver.Chrome()
+
+ # Open the website
+ driver_open.get("http://localhost/lrr/")
+ driver_open.maximize_window()
+
+ 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 a TA
+ username_input.send_keys("lanhui@qq.com")
+ password_input.send_keys("nil1234H@")
+ # Click the login button
+ login_button.click()
+ admin_tab = driver_open.find_element('id', 'admin_tab')
+ admin_tab.click()
+ print("login sucessfully")
+ cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
+ cte_instructor.click()
+ print(" everything is ok here ")
+ t = time.localtime()
+ current_time = time.strftime("%H:%M:%S", t)
+ time.sleep(25)
+
+ def createTA(driver, TA_name, emails, password):
+ full_name = driver.find_element('name', 'fullname')
+ full_name.send_keys(TA_name)
+ email = driver.find_element('name', 'email')
+ email.send_keys(emails)
+ pas = driver.find_element('name', 'password')
+ pas.send_keys(password)
+ usr_type = driver.find_element('name', 'type')
+ usr_type.click()
+ click_create = driver.find_element('name', 'create_btn')
+ click_create.click()
+
+ try:
+ fullname = "tesame"
+ email = "generat@pass.com"
+ password = ""
+ createTA(driver_open, fullname, email,
+ password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
+
+ get_output = WebDriverWait(driver_open, 5).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(20)
+
+ if txt_alert.find("TA user created successfully") == 0:
+ time.sleep(20)
+ 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 = driver_open.find_element(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(20)
+
+ login_button.click()
+
+ time.sleep(20)
+ my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
+
+ print(f"WELCOME {fullname} YOU ARE IN")
+
+ elif txt_alert.find("Email address ") == 0:
+ print(" EMAIL ALREADY EXIST ")
+ else:
+ driver_open.quit()
+ try:
+ with open('TEST_CREATING_TA.txt', 'a') as test_output:
+ test_output.write(f"\n {current_time} check this message : {txt_alert}")
+ except Exception as e:
+ print(f"unexpected error: {e}")
+
+ time.sleep(10)
+
+ finally:
+ driver_open.quit()
+
From da9e29c5b69e16ff2f72201949e2a4aa9a4cb511 Mon Sep 17 00:00:00 2001
From: newtechAI
Date: Fri, 22 Dec 2023 15:05:33 +0100
Subject: [PATCH 17/20] this is the video
https://cloud.zjnu.edu.cn/share/7c5a9ec7a87883c105687cf234
---
test/SeleniumNeil/test_cases.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/test/SeleniumNeil/test_cases.py b/test/SeleniumNeil/test_cases.py
index 88eb588..8d5bc6b 100644
--- a/test/SeleniumNeil/test_cases.py
+++ b/test/SeleniumNeil/test_cases.py
@@ -1,7 +1,6 @@
import re
import time
import pytest
-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
From cd7ece13bca5541db88ebdc21b6073c04d260705 Mon Sep 17 00:00:00 2001
From: yaaqob <3237084594@qq.com>
Date: Wed, 27 Dec 2023 00:08:41 +0800
Subject: [PATCH 18/20] MPIANA updated test script test_assign_ta.py
---
test/SeleniumMpiana/assign_ta_test.py | 65 --------------
test/SeleniumMpiana/test_assign_ta.py | 125 ++++++++++++++++++++++++++
test/SeleniumMpiana/test_results.txt | 4 +-
3 files changed, 127 insertions(+), 67 deletions(-)
delete mode 100644 test/SeleniumMpiana/assign_ta_test.py
create mode 100644 test/SeleniumMpiana/test_assign_ta.py
diff --git a/test/SeleniumMpiana/assign_ta_test.py b/test/SeleniumMpiana/assign_ta_test.py
deleted file mode 100644
index 11b6285..0000000
--- a/test/SeleniumMpiana/assign_ta_test.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import pytest
-from selenium import webdriver
-from selenium.webdriver.common.by import By
-from selenium.webdriver.support.ui import WebDriverWait
-from selenium.webdriver.support import expected_conditions as EC
-from selenium.common.exceptions import UnexpectedAlertPresentException
-
-# New instance of the Chrome driver
-driver = webdriver.Chrome()
-
-# Open the admin url
-driver.get("http://localhost/itech/lrr/Admin.php")
-
-def assign_ta(driver, course_name, ta_name):
- course_dropdown = driver.find_element('id', 'courseDropdown')
- course_dropdown.click()
- selected_course_option = WebDriverWait(driver, 1200).until(
- EC.element_to_be_clickable((By.XPATH, f"//option[text()='{course_name}']"))
- )
- selected_course_option.click()
-
- # Select the TA
- ta_dropdown = driver.find_element('id', 'taDropdown')
- ta_dropdown.click()
-
- # Check if ta_name is not null before selecting
- if ta_name:
- selected_ta_option = WebDriverWait(driver, 1200).until(
- EC.element_to_be_clickable((By.XPATH, f"//option[text()='{ta_name}']"))
- )
- selected_ta_option.click()
-
- # Click the Assign button
- assign_button = driver.find_element('id', 'assignButton')
- assign_button.click()
-
- # Use WebDriverWait for more reliable alert handling
- try:
- alert = WebDriverWait(driver, 1200).until(EC.alert_is_present())
- alert_text = alert.text
- alert.accept()
- return alert_text
- except UnexpectedAlertPresentException:
- return None
-
-# Generate all combinations of courses and TAs
-courses = ["Python", "computer", "testing"]
-tas = ["MPIANA", "KABWANGA", "mark"]
-
-@pytest.mark.parametrize("course_name, ta_name", [(course, ta) for course in courses for ta in tas])
-def assign_ta_test(course_name, ta_name):
- alert_text = assign_ta(driver, course_name, ta_name)
-
- try:
- assert "Success" in alert_text or "Error" in alert_text
- result = "Passed"
- except AssertionError:
- result = "Failed"
-
- # Write the result to the text file
- with open('test_results.txt', 'a') as result_file:
- result_file.write(f"Course={course_name}, TA={ta_name}, Result={result}, Alert={alert_text}\n")
-
-# Close the browser window
-driver.quit()
diff --git a/test/SeleniumMpiana/test_assign_ta.py b/test/SeleniumMpiana/test_assign_ta.py
new file mode 100644
index 0000000..50d9e49
--- /dev/null
+++ b/test/SeleniumMpiana/test_assign_ta.py
@@ -0,0 +1,125 @@
+import pytest
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import Select
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.common.exceptions import NoSuchElementException, UnexpectedAlertPresentException
+from selenium.webdriver.common.keys import Keys
+
+# New instance of the Chrome driver
+driver = webdriver.Chrome()
+
+# Open the login page
+driver.get("http://localhost/lrr/admin.php")
+
+# Credentials for login
+username = "lanhui@qq.com"
+password = "admin123"
+
+def login(driver, username, password):
+ try:
+ # Fill in the login form
+ user_input = WebDriverWait(driver, 10).until(
+ EC.element_to_be_clickable((By.ID, "user_name"))
+ )
+ user_input.send_keys(username)
+
+ password_input = WebDriverWait(driver, 10).until(
+ EC.element_to_be_clickable((By.ID, "user_password"))
+ )
+ password_input.send_keys(password)
+
+ # Click the login button
+ login_button = WebDriverWait(driver, 10).until(
+ EC.element_to_be_clickable((By.ID, "login_btn"))
+ )
+ login_button.click()
+
+ # Wait for the admin_tab to become clickable
+ admin_tab = WebDriverWait(driver, 10).until(
+ EC.element_to_be_clickable((By.ID, "admin_tab"))
+ )
+
+ return True
+
+ except (NoSuchElementException, UnexpectedAlertPresentException) as e:
+ return f"Error: {str(e)}"
+
+# Call the login function
+login_result = login(driver, username, password)
+
+# Click on admin_tab after successful login
+if login_result:
+ admin_tab = WebDriverWait(driver, 10).until(
+ EC.element_to_be_clickable((By.ID, "admin_tab"))
+ )
+ admin_tab.click()
+
+ # Optionally, wait for the Admin.php page to load
+ admin_url = "http://localhost/lrr/Admin.php"
+ WebDriverWait(driver, 15).until(
+ EC.url_to_be(admin_url)
+ )
+
+print(login_result)
+
+def assign_ta(driver, course_id, ta_name):
+ try:
+ # Locate the form and select the TA
+ ta_form = WebDriverWait(driver, 15).until(
+ EC.presence_of_element_located((By.XPATH, f"//form[@id='drop_menu_form_{course_id}']"))
+ )
+
+ ta_dropdown = Select(ta_form.find_element(By.XPATH, ".//select[@name='ta']"))
+ ta_dropdown.select_by_visible_text(ta_name)
+
+ # Submit the form using JavaScript
+ driver.execute_script("arguments[0].submit();", ta_form)
+
+ # Wait for an expected alert and accept it
+ WebDriverWait(driver, 10).until(EC.alert_is_present())
+ alert = driver.switch_to.alert
+ alert_text = alert.text
+ alert.accept()
+
+ return alert_text
+
+ except UnexpectedAlertPresentException as e:
+ # Unexpected alert, handle it as an error
+ return f"Error: Unexpected alert - {str(e)}"
+
+ except (NoSuchElementException, Exception) as e:
+ return f"Error: {str(e)}"
+
+
+
+# The courses and test cases to test
+courses_to_test = [
+ {"id": 1, "name": "Teecloudy - Ashly Course Testing", "ta_assignments": {"JAMES": "Ta assigned successfully."}},
+ {"id": 2, "name": "P.M2019 - Project Management", "ta_assignments": {"JAMES": "The selected TA is already assigned to this course."}},
+]
+
+# Execute the tests
+@pytest.mark.parametrize("course", courses_to_test)
+def test_assign_ta(course):
+ for ta_name, expected_result in course["ta_assignments"].items():
+ alert_text = assign_ta(driver, course["id"], ta_name)
+ # ----- ---- Print the raw strings for debugging ----- ---- ---
+ test_case_number = courses_to_test.index(course) + 1
+ print(f"Test Case {test_case_number} - {course['name']} -- {ta_name}: Expected Result={expected_result}, Actual Alert Text={alert_text}")
+
+ # Determine the result based on the comparison
+ if expected_result.lower() in alert_text.lower():
+ result = "Passed"
+ else:
+ result = "Failed"
+
+ # Write the result to a test file with test case number ---
+ with open("test_results.txt", "a") as file:
+ file.write(f"Test Case {test_case_number} - {course['name']} -- {ta_name}: Result={result}, Expected Result={expected_result}, Actual Alert Text={alert_text}\n")
+
+ # Print the result to the console ---
+ print(f"Test Case {test_case_number} - {course['name']} -- {ta_name}: Result={result}, Expected Result={expected_result}, Actual Alert Text={alert_text}")
+
+ assert result == "Passed", f"Test Case {test_case_number} failed: Result={result}, Expected Result={expected_result}, Actual Alert Text={alert_text}"
diff --git a/test/SeleniumMpiana/test_results.txt b/test/SeleniumMpiana/test_results.txt
index 139597f..4f55332 100644
--- a/test/SeleniumMpiana/test_results.txt
+++ b/test/SeleniumMpiana/test_results.txt
@@ -1,2 +1,2 @@
-
-
+Test Case 1 - Teecloudy - Ashly Course Testing -- JAMES: Result=Passed, Expected Result=Ta assigned successfully., Actual Alert Text=TA assigned successfully.
+Test Case 2 - P.M2019 - Project Management -- DIEGO: Result=Passed, Expected Result=The selected TA is already assigned to this course., Actual Alert Text=The selected TA is already assigned to this course.
From a87c741c137446b7da38d42e6824f2de138692f9 Mon Sep 17 00:00:00 2001
From: newtechAI
Date: Wed, 27 Dec 2023 22:29:25 +0100
Subject: [PATCH 19/20] Update test case script with improvements
- Removing unused statement.
- Testing already existing accounts.
---
test/SeleniumNeil/test_cases.py | 206 +++++++++++++++-----------------
1 file changed, 98 insertions(+), 108 deletions(-)
diff --git a/test/SeleniumNeil/test_cases.py b/test/SeleniumNeil/test_cases.py
index 8d5bc6b..6949c09 100644
--- a/test/SeleniumNeil/test_cases.py
+++ b/test/SeleniumNeil/test_cases.py
@@ -1,72 +1,79 @@
+# Each time you run the test script reset the database.
+# For this test script you won't need it since it changes
+# the Ta's email and name automatically
import re
import time
import pytest
+from faker import Faker
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
-@pytest.mark.generate_password_1
-def test_createTA():
-
- driver_open = webdriver.Chrome()
- driver_open.maximize_window()
+faker = Faker()
+@pytest.mark.skip(reason="function to be used in the test_scripts")
+def createTA(driver, TA_name, emails, password):
+ full_name = driver.find_element('name', 'fullname')
+ full_name.send_keys(TA_name)
+ email = driver.find_element('name', 'email')
+ email.send_keys(emails)
+ pas = driver.find_element('name', 'password')
+ pas.send_keys(password)
+ usr_type = driver.find_element('name', 'type')
+ usr_type.click()
+ click_create = driver.find_element('name', 'create_btn')
+ click_create.click()
+def login_lecturer(drivers):
# Open the website
- driver_open.get("http://localhost/lrr/")
+ drivers.get("http://localhost/lrr/")
+ drivers.maximize_window()
- username_input = driver_open.find_element('name', "user")
+ username_input = drivers.find_element('name', "user")
- password_input = driver_open.find_element('name', "password")
+ password_input = drivers.find_element('name', "password")
- login_button = driver_open.find_element('id', "login_btn")
+ login_button = drivers.find_element('id', "login_btn")
- # login as a TA
+ # login as a Lecturer
username_input.send_keys("lanhui@qq.com")
password_input.send_keys("nil1234H@")
# Click the login button
+ time.sleep(5)
login_button.click()
- admin_tab = driver_open.find_element('id', 'admin_tab')
+ admin_tab = drivers.find_element('id', 'admin_tab')
admin_tab.click()
- print("login sucessfully")
- cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
+
+ cte_instructor = drivers.find_element('id', 'tab_ins_accounts')
cte_instructor.click()
- print(" everything is ok here ")
- t = time.localtime()
- current_time = time.strftime("%H:%M:%S", t)
time.sleep(25)
- def createTA(driver, TA_name, emails, password):
- full_name = driver.find_element('name', 'fullname')
- full_name.send_keys(TA_name)
- email= driver.find_element('name', 'email')
- email.send_keys(emails)
- pas=driver.find_element('name', 'password')
- pas.send_keys(password)
- usr_type=driver.find_element('name', 'type')
- usr_type.click()
- click_create =driver.find_element('name', 'create_btn')
- click_create.click()
-
+def test_createTA():
+ driver_open = webdriver.Chrome()
+ driver_open.maximize_window()
+ login_lecturer(driver_open)
try:
- fullname = "testname"
- email = "labtest0@fgy.com"
- password = "newpasasr12345678"
- createTA(driver_open,fullname,email,password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
+ fullname = faker.name()
+ email = faker.email()
+ password = "new1452345678"
+ createTA(driver_open, fullname, email,password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
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)
+ time.sleep(20)
- if txt_alert.find("TA user created successfully")==0:
-
- logout_button = driver_open.find_element(By.XPATH, "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]")
+ if txt_alert.find("TA user created successfully") == 0:
+ logout_button = WebDriverWait(driver_open, 15).until(
+ EC.element_to_be_clickable(
+ (By.XPATH, "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]"))
+ )
+ time.sleep(5)
logout_button.click()
- time.sleep(15)
+ time.sleep(10)
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")
@@ -78,74 +85,27 @@ def test_createTA():
login_button.click()
- time.sleep(15)
- my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
- email_pattern = r"Use email (\S+) as account name"
- password_pattern = r"as password (\S+)\."
- email_match = re.search(email_pattern, txt_alert)
- password_match = re.search(password_pattern, txt_alert)
- print(f"Email: {email}")
- print(f"Password: {password}")
- print(" WELCOME TA YOU ARE IN")
+ time.sleep(20)
+ elif txt_alert.find("Email address ") == 0:
+
+ time.sleep(22)
+ driver_open.quit()
- elif txt_alert.find("Email address ")==0:
- print(" EMAIL ALREADY EXIST ")
else:
driver_open.quit()
- try:
- with open('TEST_CREATING_TA.txt', 'a') as test_output:
- test_output.write(f"\n {current_time} check this message : {txt_alert}")
- except Exception as e:
- print(f"unexpected error: {e}")
- time.sleep(10)
+ time.sleep(5)
finally:
driver_open.quit()
-@pytest.mark.generate_password_2()
+
+
def test_generate_password():
driver_open = webdriver.Chrome()
-
- # Open the website
- driver_open.get("http://localhost/lrr/")
- driver_open.maximize_window()
-
- 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 a TA
- username_input.send_keys("lanhui@qq.com")
- password_input.send_keys("nil1234H@")
- # Click the login button
- login_button.click()
- admin_tab = driver_open.find_element('id', 'admin_tab')
- admin_tab.click()
- print("login sucessfully")
- cte_instructor = driver_open.find_element('id', 'tab_ins_accounts')
- cte_instructor.click()
- print(" everything is ok here ")
- t = time.localtime()
- current_time = time.strftime("%H:%M:%S", t)
- time.sleep(25)
-
- def createTA(driver, TA_name, emails, password):
- full_name = driver.find_element('name', 'fullname')
- full_name.send_keys(TA_name)
- email = driver.find_element('name', 'email')
- email.send_keys(emails)
- pas = driver.find_element('name', 'password')
- pas.send_keys(password)
- usr_type = driver.find_element('name', 'type')
- usr_type.click()
- click_create = driver.find_element('name', 'create_btn')
- click_create.click()
-
+ login_lecturer(driver_open)
try:
- fullname = "tesame"
- email = "generat@pass.com"
+ fullname = faker.name()
+ email = faker.email()
password = ""
createTA(driver_open, fullname, email,
password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
@@ -168,8 +128,10 @@ def test_generate_password():
# Extract email and password from the matches
email = email_match.group(1)
password = password_match.group(1)
- logout_button = driver_open.find_element(By.XPATH,
- "//a[contains(@class, 'nav-link') and contains(@href, 'logout.php')]")
+ logout_button = WebDriverWait(driver_open, 10).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")
@@ -184,22 +146,50 @@ def test_generate_password():
login_button.click()
time.sleep(20)
- my_course = driver_open.find_element(By.CLASS_NAME, "display-6")
-
- print(f"WELCOME {fullname} YOU ARE IN")
elif txt_alert.find("Email address ") == 0:
- print(" EMAIL ALREADY EXIST ")
+ time.sleep(22)
+ driver_open.quit()
+
else:
driver_open.quit()
- try:
- with open('TEST_CREATING_TA.txt', 'a') as test_output:
- test_output.write(f"\n {current_time} check this message : {txt_alert}")
- except Exception as e:
- print(f"unexpected error: {e}")
- time.sleep(10)
+ 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 = "Maria"
+ email = "nreyes@example.com"
+ password = "new1452345678"
+ createTA(driver_open, fullname, email,
+ password) # CREATE A TA WITH FULLNAME lanhuitest email lanhuitest@test.com password lanhui12345678
+
+ get_output = WebDriverWait(driver_open, 5).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(20)
+
+ if txt_alert.find("TA user created successfully") == 0:
+ time.sleep(20)
+
+
+ elif txt_alert.find("Email address ") == 0:
+ time.sleep(22)
+ driver_open.quit()
+
+ else:
+ driver_open.quit()
+
+ time.sleep(5)
+
+ finally:
+ driver_open.quit()
\ No newline at end of file
From 9d1670577ea739c2b87f98ee20b8a7ed3132f6a4 Mon Sep 17 00:00:00 2001
From: newtechAI
Date: Wed, 27 Dec 2023 22:45:36 +0100
Subject: [PATCH 20/20] this is the demo
video.https://share.weiyun.com/I6ojWg0E
---
test/SeleniumNeil/test_cases.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/test/SeleniumNeil/test_cases.py b/test/SeleniumNeil/test_cases.py
index 6949c09..74c6b48 100644
--- a/test/SeleniumNeil/test_cases.py
+++ b/test/SeleniumNeil/test_cases.py
@@ -188,7 +188,6 @@ def test_existingTA():
else:
driver_open.quit()
-
time.sleep(5)
finally: