diff --git a/test/SeleniumIbrahim/test_kit/student.py b/test/SeleniumIbrahim/test_kit/student.py index ac9c5e5..838a7ba 100644 --- a/test/SeleniumIbrahim/test_kit/student.py +++ b/test/SeleniumIbrahim/test_kit/student.py @@ -196,4 +196,40 @@ class Student(Actor): return 1 def join_course_group(self): - pass \ No newline at end of file + 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 \ No newline at end of file diff --git a/test/SeleniumIbrahim/test_kit/test_suite.py b/test/SeleniumIbrahim/test_kit/test_suite.py index 082d1b5..e6628cd 100644 --- a/test/SeleniumIbrahim/test_kit/test_suite.py +++ b/test/SeleniumIbrahim/test_kit/test_suite.py @@ -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 \ No newline at end of file + admin.assign_TA() == cond + +def test_case_17(): + student.search_course_after_signup(f_name+' '+l_name, l_name+'@testing.com', 'aA124536!') == cond \ No newline at end of file diff --git a/test/SeleniumIbrahim/test_kit/utility.py b/test/SeleniumIbrahim/test_kit/utility.py index 71b658d..13c644e 100644 --- a/test/SeleniumIbrahim/test_kit/utility.py +++ b/test/SeleniumIbrahim/test_kit/utility.py @@ -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 except: print("There was a problem executing this test case")