create a test script to automate newly signup students searching for a course

AutoTesting-Golden
Goldenbwuoy 2021-12-26 17:02:55 +08:00
parent 8b91a8ed7f
commit 8ed955e32f
3 changed files with 44 additions and 5 deletions

View File

@ -197,3 +197,39 @@ class Student(Actor):
def join_course_group(self): def join_course_group(self):
pass pass
def search_course_after_signup(self, name, email, password):
""" This method automates student searching for a course after signing up.
Returns:
- 0: on success
- 1 on failure to complete case execution.
"""
try:
#Signup first.
driver = self.utility.signup(name, email, password)
#Search for course by its code.
wait = WebDriverWait(driver, 10)
course_code_field = wait.until(EC.presence_of_element_located((By.ID, "search_field")))
course_code = self.utility.getCourseCode()
course_code_field.send_keys(course_code)
find_btn = driver.find_element(By.ID, "find_btn")
find_btn.click()
#Wait until the course is found (i.e The join button will appear when the course is found)
join_btn = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "join_btn")))
return 0
#Else, if an exception occurs, log the error and abort.
except:
print("There was a problem executing this test case")
print("Error in \"search_course_after_signup()\" method, see error_log.txt for more details")
err_msg = traceback.format_exc()
self.utility.log_error(err_msg)
print("Treminating session")
self.utility.killSession(driver)
return 1

View File

@ -35,7 +35,7 @@ from instructor import Instructor
from student import Student from student import Student
from admin import Admin from admin import Admin
utility = MyUtility("http://127.0.0.1/edsa-LRR3/") utility = MyUtility("http://127.0.0.1/LRR/")
instructor = Instructor("aA124536!","202032070221", utility) instructor = Instructor("aA124536!","202032070221", utility)
student = Student("aA124536!", "202032070222", utility) student = Student("aA124536!", "202032070222", utility)
admin = Admin("aA124536!","202032070221", utility) admin = Admin("aA124536!","202032070221", utility)
@ -96,3 +96,6 @@ def test_case_15():
def test_case_16(): def test_case_16():
admin.assign_TA() == cond admin.assign_TA() == cond
def test_case_17():
student.search_course_after_signup(f_name+' '+l_name, l_name+'@testing.com', 'aA124536!') == cond

View File

@ -96,7 +96,7 @@ class MyUtility:
- password: student password string. - password: student password string.
Returns: Returns:
0 on success driver: selenium.webdriver object.
1 on failure to complete case execution. 1 on failure to complete case execution.
""" """
@ -135,7 +135,7 @@ class MyUtility:
#Sign up new student #Sign up new student
submit = signup_form.find_element(By.ID, "signup_btn") submit = signup_form.find_element(By.ID, "signup_btn")
submit.click() submit.click()
return 0 return driver
except: except:
print("There was a problem executing this test case") print("There was a problem executing this test case")