Create a test script to automate newly signup students searching for a course #32

Open
Golden wants to merge 1 commits from AutoTesting-Golden into master
3 changed files with 44 additions and 5 deletions

View File

@ -196,4 +196,40 @@ class Student(Actor):
return 1
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 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)
student = Student("aA124536!", "202032070222", utility)
admin = Admin("aA124536!","202032070221", utility)
@ -95,4 +95,7 @@ def test_case_15():
student.create_course_group() == cond
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

@Golden

Instead of using a random string, you could use the Faker package to generate names.

Hui

@Golden Instead of using a random string, you could use the [Faker](https://pypi.org/project/Faker/) package to generate names. Hui

I agree, Faker is better.

I agree, Faker is better.

View File

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

@Golden @Ibrahim

Thanks, Golden. Will this change (i.e., from return 0 to return driver) break Ibrahim's tests?

Hui

@Golden @Ibrahim Thanks, Golden. Will this change (i.e., from `return 0` to `return driver`) break Ibrahim's tests? Hui

Changing the return value to driver won't break other tests. It makes the signup function a utility function that other functions can depend on (i.e. Those functions can only be executed if the signup process is successful).

Changing the return value to driver won't break other tests. It makes the signup function a utility function that other functions can depend on (i.e. Those functions can only be executed if the signup process is successful).
except:
print("There was a problem executing this test case")