class TestImproveCourseManagement(unittest.TestCase): """T2.07 - Improve Course Management.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.teacher = Teacher(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities, existing_driver=self.teacher.driver) def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.teacher.driver.session_id), **self.ps.test_updates) self.admin = None try: self.teacher.delete() except: pass def test_view_stats_admin(self): """ Log in as Admin Click on User Menu for drop-down Click on 'Admin' on user menu Click "Stats" Click "Concept Coach" ***The user is presented with Concept Coach Statistics (t2.07.01)*** Corresponds to... t2.07.01 :return: """ # t2.07.01 --> The user is presented with Concept Coach Statistics self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Stats'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Concept Coach'))).click() assert ('/stats/concept_coach' in self.admin.current_url()), \ 'Not viewing Concept Coach stats'
class TestCourseMaintenance(unittest.TestCase): """T1.57 - Course Maintenance.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.admin.driver.session_id), **self.ps.test_updates) try: self.admin.delete() except: pass # Case C8311 - 001 - Admin | Import courses from Salesforece @pytest.mark.skipif(str(8311) not in TESTS, reason='Excluded') def test_admin_import_courses_from_salesforce_8311(self): """Import courses from Salesforce. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on the Import Courses button Expected Result: """ self.ps.test_updates['name'] = 't1.57.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.001', '8311'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8312 - 002 - Admin | Update Salesforce Staistics @pytest.mark.skipif(str(8312) not in TESTS, reason='Excluded') def test_admin_update_salesforce_statistice_8312(self): """Update Salesforce statistics. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on Update Salesforce Expected Result: """ self.ps.test_updates['name'] = 't1.57.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.002', '8312'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8313 - 003 - Admin | Exclude assesments from all courses @pytest.mark.skipif(str(8313) not in TESTS, reason='Excluded') def test_admin_exclude_assesments_from_all_courses_8313(self): """Exclude assesments from all courses. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.003', '8313'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8314 - 004 - Admin | Add a system notification @pytest.mark.skipif(str(8314) not in TESTS, reason='Excluded') def test_admin_add_a_system_notification_8314(self): """Add a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Enter a notification into the New Notification text box Click on the Add button Expected Result: A system notification is added """ self.ps.test_updates['name'] = 't1.57.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.004', '8314'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//input[@id='new_message']").send_keys('automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break # Case C8315 - 005 - Admin | Delete a system notification @pytest.mark.skipif(str(8315) not in TESTS, reason='Excluded') def test_admin_delete_a_system_notification_8315(self): """Delete a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Click on the Remove button next to a notification Click OK on the dialouge box Expected Result: A system notification is deleted """ self.ps.test_updates['name'] = 't1.57.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.005', '8315'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//input[@id='new_message']").send_keys('automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() break deleted = True notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for n in notif: if n.text.find('automated test') >= 0: deleted = False break if deleted: self.ps.test_updates['passed'] = True # Case C112519 - 006 - Admin | Add an instructor-only system notification @pytest.mark.skipif(str(112519) not in TESTS, reason='Excluded') def test_admin_add_instructor_notification_112519(self): """Add an instructor-only system notification. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.006', '112519'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//div[3]//input[@id='message']").send_keys('automated test') self.admin.driver.find_elements_by_xpath( "//input[@class='btn btn-default']")[1].click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break self.admin.sleep(5) self.ps.test_updates['passed'] = True # Case C112520 - 007 - Admin | Delete a instructor-only system notification @pytest.mark.skipif(str(112520) not in TESTS, reason='Excluded') def test_admin_delete_instructor_notification_112520(self): """Delete an instructor-only system notification. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.007', '112520'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//div[3]//input[@id='message']").send_keys('automated test') self.admin.driver.find_elements_by_xpath( "//input[@class='btn btn-default']")[1].click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break self.admin.sleep(5) deleted = True notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for n in notif: if n.text.find('automated test') >= 0: deleted = False break assert (deleted), 'notification not deleted' self.ps.test_updates['passed'] = True # Case C112521 - 008 - Student | View an active system notification @pytest.mark.skipif(str(112521) not in TESTS, reason='Excluded') def test_student_view_active_notification_112521(self): """View an active system notification. Steps: Expected Result: //div[@class='notification system']/span """ self.ps.test_updates['name'] = 't1.57.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.008', '112521'] self.ps.test_updates['passed'] = False # Test steps and verification assertions # Create notification self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find(By.XPATH, "//input[@id='message']").send_keys('automated test') self.admin.driver.find_elements_by_xpath( "//input[@class='btn btn-default']")[0].click() self.admin.sleep(5) # View notification as student student = Student(use_env_vars=True) student.login() student.select_course(appearance='physics') student.sleep(10) notifs = student.driver.find_elements_by_xpath( "//div[@class='notification system']/span") found = False for notif in notifs: if notif.text.find("automated test") >= 0: found = True student.delete() # Delete notification notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") assert (found), 'notification not seen' self.ps.test_updates['passed'] = True # Case C112522 - 009 - Teacher | View an active system notification @pytest.mark.skipif(str(112522) not in TESTS, reason='Excluded') def test_teacher_view_active_notification_112522(self): """View an active system notification. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.009', '112522'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find(By.XPATH, "//input[@id='message']").send_keys('automated test') self.admin.driver.find_elements_by_xpath( "//input[@class='btn btn-default']")[0].click() self.admin.sleep(5) # View notification as student teacher = Teacher(use_env_vars=True) teacher.login() teacher.select_course(appearance='physics') teacher.sleep(10) notifs = teacher.driver.find_elements_by_xpath( "//div[@class='notification system']/span") found = False for notif in notifs: if notif.text.find("automated test") >= 0: found = True teacher.delete() # Delete notification notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") assert (found), 'notification not seen' self.ps.test_updates['passed'] = True # Case C112523 - 010 - Teacher | View an active instructor-only # system notification @pytest.mark.skipif(str(112523) not in TESTS, reason='Excluded') def test_teacher_view_instructor_notification_112523(self): """View an active instructor-only system notification. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.010', '112523'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//div[3]//input[@id='message']").send_keys('automated test') self.admin.driver.find_elements_by_xpath( "//input[@class='btn btn-default']")[1].click() self.admin.sleep(5) # View notification as student teacher = Teacher(use_env_vars=True) teacher.login() teacher.select_course(appearance='physics') teacher.sleep(10) notifs = teacher.driver.find_elements_by_xpath( "//div[@class='notification system']/span") found = False for notif in notifs: if notif.text.find("automated test") >= 0: found = True teacher.delete() # Delete notification notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") assert (found), 'notification not seen' self.ps.test_updates['passed'] = True
def test_teacher_remove_the_last_instructor_from_the_course_8260(self): """Remove the last instructor from the course. Steps: Click on the user menu in the upper right corner of the page Click "Course Roster" Click "Remove" for an instructor under the Instructors section Click "Remove" on the box that pops up Expected Result: The instructor is removed from the Instructors list. """ self.ps.test_updates['name'] = 't1.42.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.003', '8260'] self.ps.test_updates['passed'] = False raise NotImplementedError(inspect.currentframe().f_code.co_name) self.teacher.logout() # add extra instructor through admin first admin = Admin( use_env_vars=True, existing_driver=self.teacher.driver, pasta_user=self.ps, capabilities=self.desired_capabilities ) admin.login() admin.get('https://tutor-qa.openstax.org/admin/courses/1/edit') admin.page.wait_for_page_load() teacher_name = 'Trent' admin.find( By.XPATH, '//a[contains(text(),"Teachers")]').click() admin.find( By.ID, 'course_teacher').send_keys(teacher_name) admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name) ) ).click() admin.sleep(1) admin.find( By.LINK_TEXT, 'Main Dashboard').click() admin.page.wait_for_page_load() admin.logout() # redo set-up, but make sure to go to course 1 self.teacher.login() self.teacher.get('https://tutor-qa.openstax.org/courses/1') self.teacher.open_user_menu() self.teacher.wait.until( expect.element_to_be_clickable( (By.LINK_TEXT, 'Course Settings and Roster') ) ).click() self.teacher.page.wait_for_page_load() # delete teacher teachers_list = self.teacher.find_all( By.XPATH, '//div[@class="teachers-table"]//tbody//tr') for x in range(len(teachers_list)): temp_first = self.teacher.find( By.XPATH, '//div[@class="teachers-table"]//tbody//tr[' + str(x + 1) + ']/td' ).text if temp_first == teacher_name: self.teacher.find( By.XPATH, '//div[@class="teachers-table"]//tbody//tr[' + str(x + 1) + ']//td//span[contains(text(),"Remove")]' ).click() self.teacher.sleep(1) self.teacher.find( By.XPATH, '//div[@class="popover-content"]//button' ).click() break if x == len(teachers_list) - 1: print('added teacher was not found, and not deleted') raise Exception deleted_teacher = self.teacher.driver.find_elements( By.XPATH, '//td[contains(text(),"%s")]' % teacher_name) assert(len(deleted_teacher) == 0), 'teacher not deleted' self.ps.test_updates['passed'] = True
class TestManageDistricsSchoolsAndCourses(unittest.TestCase): """T1.59 - Manage districts, schools, and courses.""" def setUp(self): """Pretest settings.""" # login as admin, go to user menu, click admin option self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: self.admin = Admin(use_env_vars=True, ) self.wait = WebDriverWait(self.admin.driver, Assignment.WAIT_TIME) self.admin.login() self.admin.goto_admin_control() def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.admin.driver.session_id), **self.ps.test_updates) try: self.admin.delete() except: pass def test_set_course_details_admin(self): """ Pre-req: "Course-Navigate" Log into Admin Click on user name for drop down Click on 'Admin' option in menu Click on 'Course Organization' for dropdown menu Click on 'Courses' Click on 'Edit' Type new course scholastic year into 'Year' text-book ***(t1.59.21)*** Type new number into number of sections ***(t1.59.22)*** Set the course start date and time under the 'Starts at' text box ***(t1.59.23)*** Set the course end date and time under the 'Ends at' textbox ***(t1.59.24)*** Set the course offering under the 'Catalog Offering' dropdown ***(t1.59.25)*** Set the course offering appearance code under the 'Appearance Code' dropdown ***(t1.59.26)*** Click 'Course duration' ***End and start dates should be displayed (t2.07.11)*** Corresponds to... t1.59 21 --> 26 :return: """ # t1.59.21 --> Type new course scholastic year into 'Year' text-book # Setup() leaves you at the admin control self.admin.goto_course_list() ### # Create the course create_new_course = self.admin.find(By.XPATH, "//a[text()='Add Course']") self.admin.driver.execute_script( 'return arguments[0].scrollIntoView();', create_new_course) create_new_course.click() self.admin.find( By.ID, "course_year").send_keys((Keys.DELETE * 4) + str(datetime.date.today().year)) # t1.59.22 --> Type new number into number of sections self.admin.find(By.ID, "course_num_sections").send_keys((Keys.DELETE) + str(1)) # t1.59.23 -->Set the course start date and time under the 'Starts at' text box self.admin.find(By.ID, "course_starts_at").click() self.admin.sleep(1) next_calendar_arrows = self.admin.find_all( By.XPATH, '//div[contains(@class,"datepicker")]' + '//button[contains(@class,"_next")]') # next_calendar_arrows[0].click() # have to find all because the two right arrows for the # start and end date have identical xpath's --> doing this allows us to pick the first or second #get the date right_now = datetime.datetime.now() hour_plus_one = str(right_now.replace(hour=right_now.hour + 1).hour) month_now = str(right_now.replace(month=right_now.month - 1).month) month_plus_one = str( right_now.month) # months are 1 minus their actual number print(right_now) print(month_now) print(hour_plus_one) print(month_plus_one) self.admin.find( By.XPATH, '//div[contains(@class,"calendar")]' + '//td[@data-date="1" and @data-month="{0}"]'.format(month_now) ).click() # Choose start date self.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"timepicker")]//div[@data-hour="{0}"]'. format(hour_plus_one)))).click() # t1.59.24 --> Set the course end date and time under the 'Ends at' textbox # Choose end date self.admin.find(By.ID, "course_ends_at").click() self.admin.sleep(1) next_calendar_arrows[-1].click() self.admin.find_all( By.XPATH, '//div[contains(@class,"calendar")]' + '//td[@data-date="1" and @data-month="{0}"]'.format(month_plus_one) )[-1].click() self.admin.sleep(5) # choose end time self.admin.find_all( By.XPATH, '//div[contains(@class,"timepicker")]//div[@data-hour="{0}"]'. format(hour_plus_one))[-1].click() # t1.59.25 --> Set the course offering under the 'Catalog Offering' dropdown self.admin.find(By.ID, "course_catalog_offering_id").click() self.admin.find( By.XPATH, '//select[@id="course_catalog_offering_id"]/option[2]').click() # t1.59.26 -->Set the course offering appearance code under the 'Appearance Code' dropdown self.admin.find(By.ID, "course_appearance_code").click() self.admin.find( By.XPATH, '//select[@id="course_appearance_code"]/option[2]').click()
class TestContractControls(unittest.TestCase): """T1.35 - Contract Controls.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.admin = Admin( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.admin.login() # make sure there are no new terms to accept try: self.admin.driver.find_element( By.ID, 'i_agree' ).click() self.admin.driver.find_element( By.ID, 'agreement_submit' ).click() except NoSuchElementException: pass # go to admin console self.wait = WebDriverWait(self.admin.driver, 15) self.admin.open_user_menu() self.admin.wait.until( expect.element_to_be_clickable( (By.LINK_TEXT, 'Admin') ) ).click() self.admin.page.wait_for_page_load() self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Legal")]').click() def tearDown(self): """Test destructor.""" self.ps.update_job( job_id=str(self.admin.driver.session_id), **self.ps.test_updates ) try: self.admin.delete() except: pass # Case C8228 - 001 - Admin | Add a new contract @pytest.mark.skipif(str(8228) not in TESTS, reason='Excluded') def test_admin_add_a_new_contract_8228(self): """Add a new contract. Steps: Click on the 'Terms' option Click on the "New Contract" Link Enter information into the Name, Title, and Content text boxes Click on the 'Create contract' button Expected Result: Contract is created as a draft. User is shown the contract they just made, and has options on what to do with it next """ self.ps.test_updates['name'] = 't1.35.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.001', '8228'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_001') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_001') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_001') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.driver.find_element( By.XPATH, '//h1[contains(text(),"Details")]').click() self.ps.test_updates['passed'] = True # Case C8229 - 002 - Admin | Cancel adding a new contract @pytest.mark.skipif(str(8229) not in TESTS, reason='Excluded') def test_admin_cancel_adding_a_new_contract_8229(self): """Cancel adding a new contract. Steps: Click on the 'Terms' option Click on the "New Contract" Link Enter information into the Name, Title, and Content text boxes Click on the 'Create contract' button Click on the Delete link Expected Result: Contract is deleted. User is taken back to the Contracts page. """ self.ps.test_updates['name'] = 't1.35.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.002', '8229'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_002') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_002') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_002') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="Delete"]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"alert-info")]') contracts = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_002")]') assert(len(contracts) == 0), 'contract not cancled' self.ps.test_updates['passed'] = True # Case C8230 - 003 - Admin | Publish a draft contract @pytest.mark.skipif(str(8230) not in TESTS, reason='Excluded') def test_admin_publish_a_draft_contract_8230(self): """Publish a draft contract. Steps: Click on the 'Terms' option Create a draft contract and return to contract list Click on the draft contract Click on the Publish link Click ok Expected Result: Draft contract is published """ self.ps.test_updates['name'] = 't1.35.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.003', '8230'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_003') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_003') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_003') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]') ) ).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_003")]').click() self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Publish")]').click() try: WebDriverWait(self.admin.driver, 3). \ until( expect.alert_is_present(), 'Timed out waiting for alert.' ) alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.ps.test_updates['passed'] = True # Case C8231 - 004 - Admin | Delete a draft contract @pytest.mark.skipif(str(8231) not in TESTS, reason='Excluded') def test_admin_delete_a_draft_contract_8231(self): """Delete a draft contract. Steps: Click on the 'Terms' option Create a draft contract and return to the contract list Click on the draft contract Click on Delete next to chosen draft contract Expected Result: Draft contract is deleted """ self.ps.test_updates['name'] = 't1.35.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.004', '8231'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() contracts_original = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_004")]') self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_004') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_004') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_004') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]') ) ).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_004")]').click() self.admin.page.wait_for_page_load() self.admin.sleep(2) self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Delete")]').click() self.admin.sleep(2) try: WebDriverWait(self.admin.driver, 3). \ until( expect.alert_is_present(), 'Timed out waiting for alert.' ) alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.admin.page.wait_for_page_load() contracts = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_004")]') self.admin.page.wait_for_page_load() assert(len(contracts) == len(contracts_original)), \ 'contract not deleted' self.ps.test_updates['passed'] = True # Case C8232 - 005 - Admin | View a current contract @pytest.mark.skipif(str(8232) not in TESTS, reason='Excluded') def test_admin_view_a_current_contract_8232(self): """View a current contract. Steps: Click on the 'Terms' option Create a contract and then return to contract list Click on chosen contract Expected Result: Displays the information of chosen contract. """ self.ps.test_updates['name'] = 't1.35.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.005', '8232'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_005') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_005') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_005') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]') ) ).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_005")]').click() self.admin.driver.find_element( By.XPATH, '//h2[contains(text(),"test_contract_title_005")]') self.ps.test_updates['passed'] = True # Case C8233 - 006 - Admin | Add a new version of a current contract @pytest.mark.skipif(str(8233) not in TESTS, reason='Excluded') def test_admin_add_a_new_version_of_a_current_contract_8233(self): """Add a new version of a current contract. Steps: Click on the 'Terms' option Click on New version next to chosen contract Update information in the Name, Title, and Content text boxes. Click on the 'Create Contract' button Expected Result: New version of contract is saved as a draft. """ self.ps.test_updates['name'] = 't1.35.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.006', '8233'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="New Version"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('NEW_006') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('NEW_006') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('NEW_006') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.driver.find_element( By.XPATH, '//h2[contains(text(),"NEW_006")]') self.ps.test_updates['passed'] = True # Case C8234 - 007 - Admin | View a contract's signatories @pytest.mark.skipif(str(8234) not in TESTS, reason='Excluded') def test_admin_view_a_contracts_signatures_8234(self): """View a contract's signatories. Steps: Click on the 'Terms' option Click on Signatures next to chosen draft contract Expected Result: Displays list of signatures for the chosen contract. """ self.ps.test_updates['name'] = 't1.35.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.007', '8234'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() wait = WebDriverWait(self.admin.driver, 45) self.admin.driver.find_element( By.XPATH, '//a[text()="Signatures"]').click() wait.until( expect.element_to_be_clickable( (By.XPATH, '//div[contains(@class,"signature_index")]') ) ) self.ps.test_updates['passed'] = True # Case C8235 - 008 - Admin | Terminate a signatory's contract @pytest.mark.skipif(str(8235) not in TESTS, reason='Excluded') def test_admin_terminate_a_signnatorys_contract_8235(self): """Terminate a signatory's contract. Steps: Click on the 'Terms' option Click on Signatures next to chosen draft contract Click on Terminate next to chosen user Click on the 'ok' button Expected Result: Selected user's signing of contract is terminated. """ self.ps.test_updates['name'] = 't1.35.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.008', '8235'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//a[text()="Signatures"]').click() # is it okay to just terminate some random person's signature wait = WebDriverWait(self.admin.driver, 45) wait.until( expect.element_to_be_clickable( (By.XPATH, '//td//a[contains(text(),"Terminate")]') ) ).click() try: WebDriverWait(self.admin.driver, 3). \ until(expect.alert_is_present(), 'Timed out waiting for PA creation ' + 'confirmation popup to appear.') alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.ps.test_updates['passed'] = True # Case C8236 - 009 - Admin | Add a targeted contract @pytest.mark.skipif(str(8236) not in TESTS, reason='Excluded') def test_admin_add_a_targeted_contract_8236(self): """Add a targeted contract. Steps: Click on the 'Targeted Contracts' option Click on the 'Add Target Contract' button Click the 'Submit' button Expected Result: User taken back to Targeted contracts page. New Targeted Contract is added """ self.ps.test_updates['name'] = 't1.35.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.009', '8236'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Targeted Contracts")]') ) ).click() orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') self.admin.driver.find_element( By.XPATH, '//a[text()="Add Targeted Contract"]').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Submit"]').click() end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') assert(len(orig_contracts) == len(end_contracts)-1), \ 'targeted contract not added' self.ps.test_updates['passed'] = True # Case C8237 - 010 - Admin | Delete a targeted contract @pytest.mark.skipif(str(8237) not in TESTS, reason='Excluded') def test_admin_delete_a_targeted_contract_8237(self): """Delete a targeted contract. Steps: Click on the user's name in the top right corner to open drop down menu Click on the 'Admin' option of the drop down menu Click on 'Legal' on the bar across the top to open drop down menu Click on the 'Targeted Contracts' option Create a targeted contract and return to the list of targed contracts Click on delete next to chosen contract Click on the 'ok' button Expected Result: Targeted contract is deleted """ self.ps.test_updates['name'] = 't1.35.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.010', '8237'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Targeted Contracts")]') ) ).click() orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') # create contract self.admin.driver.find_element( By.XPATH, '//a[text()="Add Targeted Contract"]').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Submit"]').click() # delete contract deletes = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"delete")]') deletes[-1].click() try: WebDriverWait(self.admin.driver, 3).until( expect.alert_is_present(), 'Timed out waiting for alert.' ) alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') assert(len(orig_contracts) == len(end_contracts)), \ 'targeted contract not added' self.ps.test_updates['passed'] = True # Case C8389 - 011 - Admin | Edit a draft contract @pytest.mark.skipif(str(8389) not in TESTS, reason='Excluded') def test_admin_edit_a_draft_contract_8389(self): """Edit a draft contract. Steps: Click on the 'Terms' option Create a new contract and return to list of contracts Click on Edit next to chosen draft contract Enter new information into the Name, Title, and Content text boxes Click on the 'Update Contract' button Expected Result: User is taken to Details page for selected contract. """ self.ps.test_updates['name'] = 't1.35.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.011', '8389'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_011') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_011') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_011') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[contains(text(),"test_contract_title_011")]') ) ).click() self.admin.sleep(1) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="Edit"]') ) ).click() self.admin.sleep(1) self.admin.driver.find_element( By.ID, 'contract_name').send_keys('_New') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('_New') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('_New') self.admin.driver.find_element( By.XPATH, '//input[@value="Update contract"]').click() self.admin.sleep(1) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h2[contains(text(),"test_contract_title_011_New")]') ) ) self.ps.test_updates['passed'] = True
class TestImproveCourseManagement(unittest.TestCase): """T2.07 - Improve Course Management.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.teacher = Teacher( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.admin = Admin( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities, existing_driver=self.teacher.driver ) def tearDown(self): """Test destructor.""" self.ps.update_job( job_id=str(self.teacher.driver.session_id), **self.ps.test_updates ) try: self.admin = None self.teacher.delete() except: pass # 14651 - 001 - Admin | View Student Use Statistics for Concept Coach # college assessments @pytest.mark.skipif(str(14651) not in TESTS, reason='Excluded') def test_admin_view_student_use_statistics_for_cc_college_asse_14651(self): """View Student Use Statistics for Concept Coach college assessments. Steps: Go to Tutor Click on the 'Login' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click "Admin" in the user menu Click "Stats" Click "Concept Coach" Expected Result: The user is presented with Concept Coach statistics """ self.ps.test_updates['name'] = 't2.07.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.001', '14651' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Stats') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Concept Coach') ) ).click() assert('/stats/concept_coach' in self.admin.current_url()), \ 'Not viewing Concept Coach stats' self.ps.test_updates['passed'] = True # 14652 - 002 - Teacher | Delegate teaching tasks to supporting instructors @pytest.mark.skipif(str(14652) not in TESTS, reason='Excluded') def test_teacher_delegate_teaching_tasks_to_supporting_instruc_14652(self): """Delegate teaching tasks to supporting instructors. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.002', '14652' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # 14653 - 003 - Teacher | Move a student and their data to a new section @pytest.mark.skipif(str(14653) not in TESTS, reason='Excluded') def test_teacher_move_a_student_and_their_data_to_new_section_14653(self): """Move a student and their data to a new section. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the user menu Click "Change Period" for the desired student and select a period Expected Result: Student is moved to new section with their data """ self.ps.test_updates['name'] = 't2.07.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.003', '14653' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Move the student to another period first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Change Period").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() self.teacher.sleep(5) # Verify the move, then move the student back to the original period self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[2]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") index = 0 for student in roster: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Change Period")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() break index += 1 self.teacher.sleep(2) self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[1]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") assert(first in roster[0].text and last in roster[0].text), \ 'error' self.ps.test_updates['passed'] = True # 14655 - 004 - Teacher | Drop a student from a section and hide their data @pytest.mark.skipif(str(14655) not in TESTS, reason='Excluded') def test_teacher_drop_student_from_section_and_hide_their_data_14655(self): """Drop a student from a section and hide their data. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the user menu Click "Drop" for the desired student Expected Result: The student appears under the "Dropped Students" section """ self.ps.test_updates['name'] = 't2.07.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.004', '14655' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Drop the student first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Drop").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-drop-student btn btn-danger']").click() self.teacher.sleep(5) # Verify the student was dropped and add back to active roster dropped = self.teacher.driver.find_elements_by_xpath( "//div[@class='settings-section dropped-students']/table[@class" + "='roster table table-striped table-bordered table-condensed " + "table-hover']/tbody/tr") index = 0 for student in dropped: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Add Back to Active Roster")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-undrop-student btn btn-success']" ).click() self.teacher.sleep(20) break index += 1 self.ps.test_updates['passed'] = True # 14656 - 005 - Teacher | Drop a student from a section and don't hide # their data @pytest.mark.skipif(str(14656) not in TESTS, reason='Excluded') def test_teacher_drop_a_student_from_section_and_dont_hide_dat_14656(self): """Drop a student from a section and don't hide their data. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.005', '14656' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # 14657 - 006 - Teacher | In Student Scores dropped students are not # displayed @pytest.mark.skipif(str(14657) not in TESTS, reason='Excluded') def test_teacher_in_student_scores_dropped_students_are_not_14657(self): """In Student Scores dropped students are not displayed. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the calendar dashboard Click "Drop" for the desired student Click "Student Scores" from the user menu Click on the period from which you have dropped the student Expected Result: Dropped student should not be displayed in Student Scores """ self.ps.test_updates['name'] = 't2.07.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.006', '14657' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Drop the student first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Drop").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-drop-student btn btn-danger']").click() self.teacher.sleep(5) # Go to student scores, verify the student is not seen self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Student Scores").click() self.teacher.sleep(10) odd_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedData" + "TableRow_main public_fixedDataTableRow_even public_fixedDataTa" + "ble_bodyRow']/div[@class='fixedDataTableRowLayout_body']/div" + "[@class='fixedDataTableCellGroupLayout_cellGroupWrapper'][1]/d" + "iv[@class='fixedDataTableCellGroupLayout_cellGroup']/div[@clas" + "s='fixedDataTableCellLayout_main public_fixedDataTableCell_" + "main'][1]/div[@class='fixedDataTableCellLayout_wrap1 public_fi" + "xedDataTableCell_wrap1']/div[@class='fixedDataTableCellLayout_w" + "rap2 public_fixedDataTableCell_wrap2']/div[@class='fixedDataTab" + "leCellLayout_wrap3 public_fixedDataTableCell_wrap3']/div[@class" + "='name-cell']/a[@class='student-name public_fixedDataTableCell" + "_cellContent']") even_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedDataTab" + "leRow_main public_fixedDataTableRow_highlighted public_fixedDa" + "taTableRow_odd public_fixedDataTable_bodyRow']/div[@class='fix" + "edDataTableRowLayout_body']/div[@class='fixedDataTableCellGrou" + "pLayout_cellGroupWrapper'][1]/div[@class='fixedDataTableCellGr" + "oupLayout_cellGroup']/div[@class='fixedDataTableCellLayout_mai" + "n public_fixedDataTableCell_main'][1]/div[@class='fixedDataTab" + "leCellLayout_wrap1 public_fixedDataTableCell_wrap1']/div[@clas" + "s='fixedDataTableCellLayout_wrap2 public_fixedDataTableCell_wr" + "ap2']/div[@class='fixedDataTableCellLayout_wrap3 public_fixedD" + "ataTableCell_wrap3']/div[@class='name-cell']/a[@class='student" + "-name public_fixedDataTableCell_cellContent']") found = False for student in odd_scores: if student.text.find(first) >= 0 and student.text.find(last) >= 0: found = True break if not found: for stud in even_scores: if stud.text.find(first) >= 0 and stud.text.find(last) >= 0: found = True break # Add back to active roster self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() dropped = self.teacher.driver.find_elements_by_xpath( "//div[@class='settings-section dropped-students']/table[@class" + "='roster table table-striped table-bordered table-condensed ta" + "ble-hover']/tbody/tr") index = 0 for student in dropped: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Add Back to Active Roster")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-undrop-student btn btn-success']" ).click() self.teacher.sleep(20) break index += 1 if not found: self.ps.test_updates['passed'] = True # 14850 - 007 - Teacher | In Student Scores view moved students @pytest.mark.skipif(str(14850) not in TESTS, reason='Excluded') def test_teacher_in_student_scores_view_moved_students_14850(self): """In Student Scores view moved students. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the calendar dashboard Click "Change Period" for the desired student Click on the desired period Click "Student Scores" from the user menu Click on the period to which the student was moved Expected Result: The user is presented with the moved student under their new period """ self.ps.test_updates['name'] = 't2.07.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.007', '14850' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Move the student to another period first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Change Period").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() self.teacher.sleep(5) # Go to student scores, verify the student is seen self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Student Scores").click() self.teacher.sleep(10) self.teacher.find( By.XPATH, "//nav[@class='collapse in']/ul[@class='nav nav-tabs']/li[2]/a" ).click() odd_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedData" + "TableRow_main public_fixedDataTableRow_even public_fixedDataTa" + "ble_bodyRow']/div[@class='fixedDataTableRowLayout_body']/div" + "[@class='fixedDataTableCellGroupLayout_cellGroupWrapper'][1]/d" + "iv[@class='fixedDataTableCellGroupLayout_cellGroup']/div[@clas" + "s='fixedDataTableCellLayout_main public_fixedDataTableCell_" + "main'][1]/div[@class='fixedDataTableCellLayout_wrap1 public_fi" + "xedDataTableCell_wrap1']/div[@class='fixedDataTableCellLayout_w" + "rap2 public_fixedDataTableCell_wrap2']/div[@class='fixedDataTab" + "leCellLayout_wrap3 public_fixedDataTableCell_wrap3']/div[@class" + "='name-cell']/a[@class='student-name public_fixedDataTableCell" + "_cellContent']") even_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedDataTab" + "leRow_main public_fixedDataTableRow_highlighted public_fixedDa" + "taTableRow_odd public_fixedDataTable_bodyRow']/div[@class='fix" + "edDataTableRowLayout_body']/div[@class='fixedDataTableCellGrou" + "pLayout_cellGroupWrapper'][1]/div[@class='fixedDataTableCellGr" + "oupLayout_cellGroup']/div[@class='fixedDataTableCellLayout_mai" + "n public_fixedDataTableCell_main'][1]/div[@class='fixedDataTab" + "leCellLayout_wrap1 public_fixedDataTableCell_wrap1']/div[@clas" + "s='fixedDataTableCellLayout_wrap2 public_fixedDataTableCell_wr" + "ap2']/div[@class='fixedDataTableCellLayout_wrap3 public_fixedD" + "ataTableCell_wrap3']/div[@class='name-cell']/a[@class='student" + "-name public_fixedDataTableCell_cellContent']") found = False for student in odd_scores: if student.text.find(first) >= 0 and student.text.find(last) >= 0: found = True break if found: for stud in even_scores: if stud.text.find(first) >= 0 and stud.text.find(last) >= 0: found = True break # Add student back to original period self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(10) self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[2]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") index = 0 for student in roster: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Change Period")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() break index += 1 if found: self.ps.test_updates['passed'] = True # 14658 - 008 - Teacher | Require emails for all students for roster import @pytest.mark.skipif(str(14658) not in TESTS, reason='Excluded') def test_teacher_require_emails_for_all_students_for_roster_14658(self): """Require emails for all students for roster imports. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.008', '14658' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # 14660 - 009 - Teacher | Set time zone for a course @pytest.mark.skipif(str(14660) not in TESTS, reason='Excluded') def test_teacher_set_time_zone_for_a_course_14660(self): """Set time zone for a course. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" Click "Change Course Timezone" Select the desired timezone Click Save Expected Result: The time zone is set """ self.ps.test_updates['name'] = 't2.07.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.009', '14660' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Change the timezone self.teacher.driver.find_elements_by_xpath( "//button[@class='edit-course btn btn-link']")[1].click() self.teacher.sleep(2) self.teacher.find( By.XPATH, "//div[@class='tutor-radio']/label").click() self.teacher.find( By.XPATH, "//button[@class='async-button -edit-course-" + "confirm btn btn-default']").click() self.teacher.sleep(5) # Verify the change and change the time back to Central self.teacher.driver.find_elements_by_xpath( "//button[@class='edit-course btn btn-link']")[1].click() assert('Central Time' not in self.teacher.find( By.XPATH, "//div[@class='tutor-radio active']/label").text), \ 'Not viewing Concept Coach stats' self.teacher.sleep(2) options = self.teacher.driver.find_elements_by_xpath( "//div[@class='tutor-radio']/label") for timezone in options: if timezone.text.find('Central Time') >= 0: timezone.click() break self.teacher.find( By.XPATH, "//button[@class='async-button -edit-course-" + "confirm btn btn-default']").click() self.ps.test_updates['passed'] = True # 14661 - 010 - System | Distinguish between high school and college # courses @pytest.mark.skipif(str(14661) not in TESTS, reason='Excluded') def test_system_distinguish_between_hs_and_college_courses_14661(self): """Distinguish between high school and college courses. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.010', '14661' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True
class TestImproveCourseManagement(unittest.TestCase): """T2.07 - Improve Course Management.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.teacher = Teacher(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities, existing_driver=self.teacher.driver) def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.teacher.driver.session_id), **self.ps.test_updates) self.admin = None try: self.teacher.delete() except: pass # 14651 - 001 - Admin | View Student Use Statistics for Concept Coach # college assessments @pytest.mark.skipif(str(14651) not in TESTS, reason='Excluded') def test_admin_view_student_use_statistics_for_cc_college_asse_14651(self): """View Student Use Statistics for Concept Coach college assessments. Steps: Go to Tutor Click on the 'Login' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click "Admin" in the user menu Click "Stats" Click "Concept Coach" Expected Result: The user is presented with Concept Coach statistics """ self.ps.test_updates['name'] = 't2.07.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.001', '14651'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Stats'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Concept Coach'))).click() assert('/stats/concept_coach' in self.admin.current_url()), \ 'Not viewing Concept Coach stats' self.ps.test_updates['passed'] = True ''' # 14652 - 002 - Teacher | Delegate teaching tasks to supporting instructors @pytest.mark.skipif(str(14652) not in TESTS, reason='Excluded') def test_teacher_delegate_teaching_tasks_to_supporting_instruc_14652(self): """Delegate teaching tasks to supporting instructors. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.002', '14652' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True ''' ''' # 14653 - 003 - Teacher | Move a student and their data to a new section @pytest.mark.skipif(str(14653) not in TESTS, reason='Excluded') def test_teacher_move_a_student_and_their_data_to_new_section_14653(self): """Move a student and their data to a new section. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the user menu Click "Change Period" for the desired student and select a period Expected Result: Student is moved to new section with their data """ self.ps.test_updates['name'] = 't2.07.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.003', '14653' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Move the student to another period first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Change Period").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() self.teacher.sleep(5) # Verify the move, then move the student back to the original period self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[2]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") index = 0 for student in roster: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Change Period")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() break index += 1 self.teacher.sleep(2) self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[1]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") assert(first in roster[0].text and last in roster[0].text), \ 'error' self.ps.test_updates['passed'] = True # 14655 - 004 - Teacher | Drop a student from a section and hide their data @pytest.mark.skipif(str(14655) not in TESTS, reason='Excluded') def test_teacher_drop_student_from_section_and_hide_their_data_14655(self): """Drop a student from a section and hide their data. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the user menu Click "Drop" for the desired student Expected Result: The student appears under the "Dropped Students" section """ self.ps.test_updates['name'] = 't2.07.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.004', '14655' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find( By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Drop the student first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Drop").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-drop-student btn btn-danger']").click() self.teacher.sleep(5) # Verify the student was dropped and add back to active roster dropped = self.teacher.driver.find_elements_by_xpath( "//div[@class='settings-section dropped-students']/table[@class" + "='roster table table-striped table-bordered table-condensed " + "table-hover']/tbody/tr") index = 0 for student in dropped: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Add Back to Active Roster")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-undrop-student btn btn-success']" ).click() self.teacher.sleep(20) break index += 1 self.ps.test_updates['passed'] = True # 14656 - 005 - Teacher | Drop a student from a section and don't hide # their data @pytest.mark.skipif(str(14656) not in TESTS, reason='Excluded') def test_teacher_drop_a_student_from_section_and_dont_hide_dat_14656(self): """Drop a student from a section and don't hide their data. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 't2', 't2.07', 't2.07.005', '14656' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True ''' # 14657 - 006 - Teacher | In Student Scores dropped students are not # displayed @pytest.mark.skipif(str(14657) not in TESTS, reason='Excluded') def test_teacher_in_student_scores_dropped_students_are_not_14657(self): """In Student Scores dropped students are not displayed. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the calendar dashboard Click "Drop" for the desired student Click "Student Scores" from the user menu Click on the period from which you have dropped the student Expected Result: Dropped student should not be displayed in Student Scores """ self.ps.test_updates['name'] = 't2.07.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.006', '14657'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Drop the student first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Drop").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-drop-student btn btn-danger']").click() self.teacher.sleep(5) # Go to student scores, verify the student is not seen self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Student Scores").click() self.teacher.sleep(10) odd_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedData" + "TableRow_main public_fixedDataTableRow_even public_fixedDataTa" + "ble_bodyRow']/div[@class='fixedDataTableRowLayout_body']/div" + "[@class='fixedDataTableCellGroupLayout_cellGroupWrapper'][1]/d" + "iv[@class='fixedDataTableCellGroupLayout_cellGroup']/div[@clas" + "s='fixedDataTableCellLayout_main public_fixedDataTableCell_" + "main'][1]/div[@class='fixedDataTableCellLayout_wrap1 public_fi" + "xedDataTableCell_wrap1']/div[@class='fixedDataTableCellLayout_w" + "rap2 public_fixedDataTableCell_wrap2']/div[@class='fixedDataTab" + "leCellLayout_wrap3 public_fixedDataTableCell_wrap3']/div[@class" + "='name-cell']/a[@class='student-name public_fixedDataTableCell" + "_cellContent']") even_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedDataTab" + "leRow_main public_fixedDataTableRow_highlighted public_fixedDa" + "taTableRow_odd public_fixedDataTable_bodyRow']/div[@class='fix" + "edDataTableRowLayout_body']/div[@class='fixedDataTableCellGrou" + "pLayout_cellGroupWrapper'][1]/div[@class='fixedDataTableCellGr" + "oupLayout_cellGroup']/div[@class='fixedDataTableCellLayout_mai" + "n public_fixedDataTableCell_main'][1]/div[@class='fixedDataTab" + "leCellLayout_wrap1 public_fixedDataTableCell_wrap1']/div[@clas" + "s='fixedDataTableCellLayout_wrap2 public_fixedDataTableCell_wr" + "ap2']/div[@class='fixedDataTableCellLayout_wrap3 public_fixedD" + "ataTableCell_wrap3']/div[@class='name-cell']/a[@class='student" + "-name public_fixedDataTableCell_cellContent']") found = False for student in odd_scores: if student.text.find(first) >= 0 and student.text.find(last) >= 0: found = True break if not found: for stud in even_scores: if stud.text.find(first) >= 0 and stud.text.find(last) >= 0: found = True break # Add back to active roster self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() dropped = self.teacher.driver.find_elements_by_xpath( "//div[@class='settings-section dropped-students']/table[@class" + "='roster table table-striped table-bordered table-condensed ta" + "ble-hover']/tbody/tr") index = 0 for student in dropped: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Add Back to Active Roster")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//button[@class='-undrop-student btn btn-success']" ).click() self.teacher.sleep(20) break index += 1 if not found: self.ps.test_updates['passed'] = True # 14850 - 007 - Teacher | In Student Scores view moved students @pytest.mark.skipif(str(14850) not in TESTS, reason='Excluded') def test_teacher_in_student_scores_view_moved_students_14850(self): """In Student Scores view moved students. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" from the calendar dashboard Click "Change Period" for the desired student Click on the desired period Click "Student Scores" from the user menu Click on the period to which the student was moved Expected Result: The user is presented with the moved student under their new period """ self.ps.test_updates['name'] = 't2.07.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.007', '14850'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Move the student to another period first = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[1]" ).text last = self.teacher.find( By.XPATH, "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr[1]/td[2]" ).text self.teacher.find(By.PARTIAL_LINK_TEXT, "Change Period").click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() self.teacher.sleep(5) # Go to student scores, verify the student is seen self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Student Scores").click() self.teacher.sleep(10) self.teacher.find( By.XPATH, "//nav[@class='collapse in']/ul[@class='nav nav-tabs']/li[2]/a" ).click() odd_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedData" + "TableRow_main public_fixedDataTableRow_even public_fixedDataTa" + "ble_bodyRow']/div[@class='fixedDataTableRowLayout_body']/div" + "[@class='fixedDataTableCellGroupLayout_cellGroupWrapper'][1]/d" + "iv[@class='fixedDataTableCellGroupLayout_cellGroup']/div[@clas" + "s='fixedDataTableCellLayout_main public_fixedDataTableCell_" + "main'][1]/div[@class='fixedDataTableCellLayout_wrap1 public_fi" + "xedDataTableCell_wrap1']/div[@class='fixedDataTableCellLayout_w" + "rap2 public_fixedDataTableCell_wrap2']/div[@class='fixedDataTab" + "leCellLayout_wrap3 public_fixedDataTableCell_wrap3']/div[@class" + "='name-cell']/a[@class='student-name public_fixedDataTableCell" + "_cellContent']") even_scores = self.teacher.driver.find_elements_by_xpath( "//div[@class='fixedDataTableRowLayout_main public_fixedDataTab" + "leRow_main public_fixedDataTableRow_highlighted public_fixedDa" + "taTableRow_odd public_fixedDataTable_bodyRow']/div[@class='fix" + "edDataTableRowLayout_body']/div[@class='fixedDataTableCellGrou" + "pLayout_cellGroupWrapper'][1]/div[@class='fixedDataTableCellGr" + "oupLayout_cellGroup']/div[@class='fixedDataTableCellLayout_mai" + "n public_fixedDataTableCell_main'][1]/div[@class='fixedDataTab" + "leCellLayout_wrap1 public_fixedDataTableCell_wrap1']/div[@clas" + "s='fixedDataTableCellLayout_wrap2 public_fixedDataTableCell_wr" + "ap2']/div[@class='fixedDataTableCellLayout_wrap3 public_fixedD" + "ataTableCell_wrap3']/div[@class='name-cell']/a[@class='student" + "-name public_fixedDataTableCell_cellContent']") found = False for student in odd_scores: if student.text.find(first) >= 0 and student.text.find(last) >= 0: found = True break if found: for stud in even_scores: if stud.text.find(first) >= 0 and stud.text.find(last) >= 0: found = True break # Add student back to original period self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(10) self.teacher.find( By.XPATH, "//div[@class='roster']/div[@class='settings-section periods']" + "/ul[@class='nav nav-tabs']/li[2]/a").click() roster = self.teacher.driver.find_elements_by_xpath( "//div[@class='period']/table[@class='roster table table-striped" + " table-bordered table-condensed table-hover']/tbody/tr") index = 0 for student in roster: if student.text.find(first) >= 0 and student.text.find(last) >= 0: self.teacher.driver.find_elements_by_partial_link_text( "Change Period")[index].click() self.teacher.sleep(1) self.teacher.find( By.XPATH, "//ul[@class='nav nav-pills nav-stacked']/li/a").click() break index += 1 if found: self.ps.test_updates['passed'] = True # 14658 - 008 - Teacher | Require emails for all students for roster import @pytest.mark.skipif(str(14658) not in TESTS, reason='Excluded') def test_teacher_require_emails_for_all_students_for_roster_14658(self): """Require emails for all students for roster imports. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.008', '14658'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # 14660 - 009 - Teacher | Set time zone for a course @pytest.mark.skipif(str(14660) not in TESTS, reason='Excluded') def test_teacher_set_time_zone_for_a_course_14660(self): """Set time zone for a course. Steps: If the user has more than one course, click on a Tutor course name Click "Course Settings and Roster" Click "Change Course Timezone" Select the desired timezone Click Save Expected Result: The time zone is set """ self.ps.test_updates['name'] = 't2.07.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.009', '14660'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.select_course(appearance='physics') self.teacher.open_user_menu() self.teacher.find(By.PARTIAL_LINK_TEXT, "Course Settings and Roster").click() self.teacher.sleep(5) # Change the timezone self.teacher.driver.find_elements_by_xpath( "//button[@class='edit-course btn btn-link']")[1].click() self.teacher.sleep(2) self.teacher.find(By.XPATH, "//div[@class='tutor-radio']/label").click() self.teacher.find( By.XPATH, "//button[@class='async-button -edit-course-" + "confirm btn btn-default']").click() self.teacher.sleep(5) # Verify the change and change the time back to Central self.teacher.driver.find_elements_by_xpath( "//button[@class='edit-course btn btn-link']")[1].click() assert('Central Time' not in self.teacher.find( By.XPATH, "//div[@class='tutor-radio active']/label").text), \ 'Not viewing Concept Coach stats' self.teacher.sleep(2) options = self.teacher.driver.find_elements_by_xpath( "//div[@class='tutor-radio']/label") for timezone in options: if timezone.text.find('Central Time') >= 0: timezone.click() break self.teacher.find( By.XPATH, "//button[@class='async-button -edit-course-" + "confirm btn btn-default']").click() self.ps.test_updates['passed'] = True # 14661 - 010 - System | Distinguish between high school and college # courses @pytest.mark.skipif(str(14661) not in TESTS, reason='Excluded') def test_system_distinguish_between_hs_and_college_courses_14661(self): """Distinguish between high school and college courses. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.010', '14661'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # 116648 - 011 - Admin | View the start and end dates from the # admin console course list @pytest.mark.skipif(str(116648) not in TESTS, reason='Excluded') def test_admin_view_start_end_dates_from_course_list_116648(self): """View the start and end dates from the admin console course list. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.07.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.07', 't2.07.011', '116648'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Course Organization'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Courses'))).click() self.admin.sleep(3) self.admin.find(By.XPATH, "//div[@class='course-duration']") self.ps.test_updates['passed'] = True
class TestCourseMaintenance(unittest.TestCase): """T1.57 - Course Maintenance.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.admin = Admin( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) def tearDown(self): """Test destructor.""" self.ps.update_job( job_id=str(self.admin.driver.session_id), **self.ps.test_updates ) try: self.admin.delete() except: pass # Case C8311 - 001 - Admin | Import courses from Salesforece @pytest.mark.skipif(str(8311) not in TESTS, reason='Excluded') def test_admin_import_courses_from_salesforce_8311(self): """Import courses from Salesforce. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on the Import Courses button Expected Result: """ self.ps.test_updates['name'] = 't1.57.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.001', '8311'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8312 - 002 - Admin | Update Salesforce Staistics @pytest.mark.skipif(str(8312) not in TESTS, reason='Excluded') def test_admin_update_salesforce_statistice_8312(self): """Update Salesforce statistics. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on Update Salesforce Expected Result: """ self.ps.test_updates['name'] = 't1.57.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.002', '8312'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8313 - 003 - Admin | Exclude assesments from all courses @pytest.mark.skipif(str(8313) not in TESTS, reason='Excluded') def test_admin_exclude_assesments_from_all_courses_8313(self): """Exclude assesments from all courses. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.003', '8313'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8314 - 004 - Admin | Add a system notification @pytest.mark.skipif(str(8314) not in TESTS, reason='Excluded') def test_admin_add_a_system_notification_8314(self): """Add a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Enter a notification into the New Notification text box Click on the Add button Expected Result: A system notification is added """ self.ps.test_updates['name'] = 't1.57.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.004', '8314'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications') ) ).click() self.admin.sleep(5) self.admin.find(By.XPATH, "//input[@id='new_message']").send_keys( 'automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break # Case C8315 - 005 - Admin | Delete a system notification @pytest.mark.skipif(str(8315) not in TESTS, reason='Excluded') def test_admin_delete_a_system_notification_8315(self): """Delete a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Click on the Remove button next to a notification Click OK on the dialouge box Expected Result: A system notification is deleted """ self.ps.test_updates['name'] = 't1.57.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.005', '8315'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications') ) ).click() self.admin.sleep(5) self.admin.find(By.XPATH, "//input[@id='new_message']").send_keys( 'automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() break deleted = True notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for n in notif: if n.text.find('automated test') >= 0: deleted = False break if deleted: self.ps.test_updates['passed'] = True
class TestAdminAndTeacherCourseSetup(unittest.TestCase): """CC1.10 - Admin and Teacher Course Setup.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.teacher = Teacher( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.admin = Admin( use_env_vars=True, existing_driver=self.teacher.driver, pasta_user=self.ps, capabilities=self.desired_capabilities ) def tearDown(self): """Test destructor.""" self.ps.update_job( job_id=str(self.teacher.driver.session_id), **self.ps.test_updates ) try: self.admin.driver = None self.teacher.delete() except: pass # Case C7715 - 001 - Admin | Send course setup data from Sales Force @pytest.mark.skipif(str(7715) not in TESTS, reason='Excluded') def test_admin_send_course_setup_data_from_sales_force_7715(self): """Send course setup data from Sales Force. Steps: Go to tutor-staging.openstax.org and login as admin Click on the user menu Select the Admin option Click on Salesforce on the header Expected Result: """ self.ps.test_updates['name'] = 'cc1.10.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.001', '7715' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Admin' ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Salesforce') ) ).click() assert('salesforce' in self.admin.current_url()), 'not at salesforce' self.ps.test_updates['passed'] = True # Case C7716 - 002 - System | Course registration codes are emailed to the # teacher once the course is set up @pytest.mark.skipif(str(7716) not in TESTS, reason='Excluded') def test_system_registration_codes_are_emailed_to_teacher_7716(self): """Registration codes are emailed to teacher once the course is set up. Steps: Expected Result: """ self.ps.test_updates['name'] = 'cc1.10.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.002', '7716' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C7717 - 003 - Teacher | Use a teacher registration code to access # their course @pytest.mark.skipif(str(7717) not in TESTS, reason='Excluded') def test_teacher_use_teacher_registration_code_to_access_course_7717(self): """Use a teacher registration code to access their course. Steps: Expected Result: """ self.ps.test_updates['name'] = 'cc1.10.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.003', '7717' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C7718 - 004 - Teacher | Create course periods @pytest.mark.skipif(str(7718) not in TESTS, reason='Excluded') def test_teacher_create_course_periods_7718(self): """Create course periods. Steps: go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click "+ Add section" Enter a section name into the section Name text box Expected Result: New course section created """ self.ps.test_updates['name'] = 'cc1.10.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.004', '7718' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"add-period")]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys('test_period') self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Add"]' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="test_period"]') ) ) self.ps.test_updates['passed'] = True # Case C7719 - 005 - Teacher | View student enrollment code for # course period @pytest.mark.skipif(str(7719) not in TESTS, reason='Excluded') def test_teacher_view_student_enrollment_code_for_course_period_7719(self): """View the student enrollment code for a course period. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for selected section Click 'Get Student Enrollment Code' Expected Result: Student Enrollment code displayed along with instruction teacher can send to students on how to use enrollment code """ self.ps.test_updates['name'] = 'cc1.10.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.005', '7719' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//button[contains(@class,"show-enrollment-code")]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="enrollment-code"]') ) ) self.ps.test_updates['passed'] = True # Case C7720 - 006 - Teacher | Rename a course period @pytest.mark.skipif(str(7720) not in TESTS, reason='Excluded') def test_teacher_rename_a_course_period_7720(self): """Rename a course period. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for selected section Click 'Rename section' Enter new section name into the section Name text box Click on the 'Rename' button Expected Result: Section is renamed """ self.ps.test_updates['name'] = 'cc1.10.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.006', '7720' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() period_name = self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab"]') ) ).text self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[contains(@class,"rename-period")]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys('_EDIT') self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Rename"]' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '_EDIT"]') ) ) # then set it back to what it was before self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[contains(@class,"rename-period")]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys(Keys.BACK_SPACE * 5) self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Rename"]' ).click() self.ps.test_updates['passed'] = True # Case C7721 - 007 - Teacher | Archive an empty period @pytest.mark.skipif(str(7721) not in TESTS, reason='Excluded') def test_teacher_remove_an_empty_period_7721(self): """Remove an empty period. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for selected empty section Click 'Archive section' Click on the 'Archive' button Expected Result: Section is archived """ self.ps.test_updates['name'] = 'cc1.10.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.007', '7721' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions section_name = 'test_' + str(randint(0, 1000)) self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # create an empty section self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"add-period")]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys(section_name) self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Add"]' ).click() # archive the section just created self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + section_name + '"]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[contains(@class,"archive-period")]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@role="tooltip"]//button' + '//span[contains(text(),"Archive")]') ) ).click() self.teacher.sleep(2) archived = self.teacher.driver.find_elements( By.XPATH, '//li//a[@role="tab" and text()="' + section_name + '"]') assert(len(archived) == 0), ' not archived' self.ps.test_updates['passed'] = True # Case C7722 - 008 - Teacher | Archive a non-empty period @pytest.mark.skipif(str(7722) not in TESTS, reason='Excluded') def test_teacher_archive_a_nonempty_periods_7722(self): """Error message displayed if attempting to remove a non-empty period. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for selected non-empty section Click 'Archive section' Click Archive Expected Result: Section is archived """ self.ps.test_updates['name'] = 'cc1.10.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.008', '7722' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # name of period to archive (first tab) period_name = self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab"]') ) ).text # archive the section self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[contains(@class,"archive-period")]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@role="tooltip"]//button' + '//span[contains(text(),"Archive")]') ) ).click() self.teacher.sleep(2) archived = self.teacher.driver.find_elements( By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') assert(len(archived) == 0), ' not archived' # add the archived period back self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"view-archived-periods")]//button') ) ).click() periods = self.teacher.driver.find_elements( By.XPATH, '//div[@class="modal-content"]//tbody//tr' ) for period in periods: try: period.find_element( By.XPATH, ".//td[text()='" + period_name + "']") period.find_element( By.XPATH, ".//td//span[contains(@class,'restore-period')]//button" ).click() break except NoSuchElementException: if period == periods[-1]: raise Exception self.teacher.sleep(2) self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') ) ) self.ps.test_updates['passed'] = True # Case C58354 - 009 - Teacher | Unarchive a section @pytest.mark.skipif(str(58354) not in TESTS, reason='Excluded') def test_teacher_unarchive_a_section_58354(self): """Unarchive a section. Steps: go to tutor-qa.openstax.org log in as a teacher click on a Concept Coach book click on the user menu select course roster Click "View Archived Section" Click "Unarchive" for the desired section Expected Result: section is unarchived """ self.ps.test_updates['name'] = 'cc1.10.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.009', '58354' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # name of period to archive (first tab) period_name = self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab"]') ) ).text # archive the section self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[contains(@class,"archive-period")]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@role="tooltip"]//button' + '//span[contains(text(),"Archive")]') ) ).click() self.teacher.sleep(2) archived = self.teacher.driver.find_elements( By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') assert(len(archived) == 0), ' not archived' # add the archived period back self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"view-archived-periods")]//button') ) ).click() periods = self.teacher.driver.find_elements( By.XPATH, '//div[@class="modal-content"]//tbody//tr' ) for period in periods: try: period.find_element( By.XPATH, ".//td[text()='" + period_name + "']") period.find_element( By.XPATH, ".//td//span[contains(@class,'restore-period')]//button" ).click() break except NoSuchElementException: if period == periods[-1]: raise Exception self.teacher.sleep(2) self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]') ) ) self.ps.test_updates['passed'] = True # Case C7723 - 010 - Teacher | Rename the course @pytest.mark.skipif(str(7723) not in TESTS, reason='Excluded') def test_teacher_rename_the_course_7723(self): """Rename the course. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click 'Rename Course' Enter a new Course name into the Course Name text box Click on the 'Rename' button Expected Result: Course is renamed. """ self.ps.test_updates['name'] = 'cc1.10.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.010', '7723' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # rename section self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[@class="-rename-course-link"]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys("_EDIT") self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Rename"]' ).click() # check that the name was changed self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="course-settings-title"]' + '//span[contains(text(),"_EDIT")]') ) ) # change it back self.teacher.sleep(1) self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[@class="-rename-course-link"]//button') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="modal-content"]//input[@type="text"]') ) ).send_keys(Keys.BACK_SPACE * 5) self.teacher.driver.find_element( By.XPATH, '//div[@class="modal-content"]//button/span[text()="Rename"]' ).click() self.ps.test_updates['passed'] = True # Case C7724 - 011 - Teacher | Remove other teachers from the course @pytest.mark.skipif(str(7724) not in TESTS, reason='Excluded') def test_teacher_remove_other_teachers_from_the_course_7724(self): """Remove other teachers from the course. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on 'Remove' on the same row as selected teacher Click on the 'Remove' button Expected Result: Instructor is removed from the course """ self.ps.test_updates['name'] = 'cc1.10.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.011', '7724' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.driver.get( 'https://tutor-qa.openstax.org/admin/courses/8/edit') self.admin.page.wait_for_page_load() teacher_name = 'Trent' self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Teachers")]').click() self.admin.driver.find_element( By.ID, 'course_teacher').send_keys(teacher_name) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name) ) ).click() self.admin.sleep(1) self.admin.driver.find_element( By.LINK_TEXT, 'Main Dashboard').click() self.admin.page.wait_for_page_load() self.admin.logout() # redo set-up, but make sure to go to course 8 self.teacher.login() self.teacher.driver.get('https://tutor-qa.openstax.org/courses/8') self.teacher.open_user_menu() self.teacher.wait.until( expect.element_to_be_clickable( (By.LINK_TEXT, 'Course Settings and Roster') ) ).click() self.teacher.page.wait_for_page_load() # delete teacher teachers_list = self.teacher.driver.find_elements( By.XPATH, '//div[@class="teachers-table"]//tbody//tr') for x in teachers_list: temp_first = x.find_element( By.XPATH, './td[1]' ).text if temp_first == teacher_name: x.find_element( By.XPATH, './/td//span[contains(text(),"Remove")]' ).click() self.teacher.sleep(1) self.teacher.driver.find_element( By.XPATH, '//div[@class="popover-content"]//button' ).click() break if x == teachers_list[-1]: print('added teacher was not found, and not deleted') raise Exception deleted_teacher = self.teacher.driver.find_elements( By.XPATH, '//td[contains(text(),"%s")]' % teacher_name) assert(len(deleted_teacher) == 0), 'teacher not deleted' self.ps.test_updates['passed'] = True # come back to this because adding teacher through admin first # Case C7725 - 012 - Teacher | Remove themself from the course @pytest.mark.skipif(str(7725) not in TESTS, reason='Excluded') def test_teacher_remove_themself_from_the_course_7725(self): """Remove themself from the course. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on 'Remove' on the same row as themselves Click on the 'Remove' button Expected Result: Teacher is removed from course and taken back to dashboard """ self.ps.test_updates['name'] = 'cc1.10.012' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.012', '7725' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.driver.get( 'https://tutor-qa.openstax.org/admin/courses/8/edit') self.admin.page.wait_for_page_load() teacher_name = 'Trent' self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Teachers")]').click() self.admin.driver.find_element( By.ID, 'course_teacher').send_keys(teacher_name) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name) ) ).click() self.admin.sleep(1) self.admin.driver.find_element( By.LINK_TEXT, 'Main Dashboard').click() self.admin.page.wait_for_page_load() self.admin.logout() # redo set-up, but make sure to go to course 8 # login as the teacher just added to the course teacher2 = Teacher( username='******', password=os.getenv('TEACHER_PASSWORD'), existing_driver=self.teacher.driver ) teacher2.login() teacher2.driver.get('https://tutor-qa.openstax.org/courses/8') teacher2.open_user_menu() teacher2.wait.until( expect.element_to_be_clickable( (By.LINK_TEXT, 'Course Settings and Roster') ) ).click() teacher2.page.wait_for_page_load() # delete teacher teachers_list = teacher2.driver.find_elements( By.XPATH, '//div[@class="teachers-table"]//tbody//tr') for x in teachers_list: temp_first = x.find_element( By.XPATH, './td[1]' ).text if temp_first == teacher_name: x.find_element( By.XPATH, './/td//span[contains(text(),"Remove")]' ).click() teacher2.sleep(1) teacher2.driver.find_element( By.XPATH, '//div[@class="popover-content"]//button' ).click() break if x == teachers_list[-1]: print('added teacher was not found, and not deleted') raise Exception # after removing self from course taken to dashboard # or course if only 1 other course assert('/courses/8' not in teacher2.current_url()), \ 'teacher not deleted' teacher2.delete() self.ps.test_updates['passed'] = True # Case C7726 - 013 - Teacher | Transfer a student to another period @pytest.mark.skipif(str(7726) not in TESTS, reason='Excluded') def test_teacher_transfer_a_student_to_another_period_7726(self): """Transfer a student to another period. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for section selected student is currently enrolled in Click on 'Change Section' on the row of the selected student Click on section to move student to Expected Result: Student is moved to chosen section """ self.ps.test_updates['name'] = 'cc1.10.013' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.013', '7726' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # move student first_student = self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="period"]//tbody/tr[1]') ) ) student_name = first_student.find_element( By.XPATH, './/td[1]').text first_student.find_element( By.XPATH, './/td[@class="actions"]/a[@aria-describedby="change-period"]' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="popover-content"]//li[1]') ) ).click() # check that student was moved self.teacher.sleep(2) self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//li[@tabindex="1"]//a[@role="tab"]') ) ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="period"]//tbody/tr' + '//td[text()="' + student_name + '"]') ) ) self.ps.test_updates['passed'] = True # Case C7727 - 014 - Teacher | Remove a student from a course @pytest.mark.skipif(str(7727) not in TESTS, reason='Excluded') def test_teacher_remove_a_student_from_a_course_7727(self): """Remove a student from a course. Steps: Go to Tutor Log in as a teacher Click on a Concept Coach book Click on the user menu Select course roster Click on tab for section selected student is currently enrolled in Click on 'Drop' on the row of the selected student Click on the 'Drop' button Expected Result: Student is dropped from the course """ self.ps.test_updates['name'] = 'cc1.10.014' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.014', '7727' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard")]' ).click() self.teacher.page.wait_for_page_load() self.teacher.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Course Settings and Roster' ).click() # drop student first_student = self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="period"]//tbody/tr[1]') ) ) student_name = first_student.find_element( By.XPATH, './/td[1]').text first_student.find_element( By.XPATH, './/td[@class="actions"]/a[@aria-describedby="drop-student"]' ).click() self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@id="drop-student"]//button') ) ).click() # check that student was removed self.teacher.sleep(2) self.teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"dropped-students")]//tbody/tr' + '//td[text()="' + student_name + '"]') ) ) self.ps.test_updates['passed'] = True # Case C7728 - 015 - Admin | Impersonate a teacher @pytest.mark.skipif(str(7728) not in TESTS, reason='Excluded') def test_admin_impersonate_a_teacher_7728(self): """Impersonate a teacher. Steps: Go to Tutor Click on the 'Login' button Enter the admin user account in the username and password text boxes Click on the 'Sign in' button Click on the user's name in the top right corner to open drop down menu Click on the 'Admin' option of the drop down menu Click on 'Users' on the bar across the top [optional] Enter a teacher name into the search here text box Click on the 'Search' button Click on the 'Sign in as' button next to chosen teacher Expected Result: Signs in as chosen chosen teacher. Goes to chosen teacher's initial screen after login If multiple courses list of textbooks If one course straight to dashboard """ self.ps.test_updates['name'] = 'cc1.10.015' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.015', '7728' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.admin.driver.find_element( By.LINK_TEXT, 'Admin' ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Users') ) ).click() self.admin.page.wait_for_page_load() self.admin.driver.find_element(By.ID, 'query').send_keys('teacher01') self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Sign in as")]') ) ).click() self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//span[contains(text(),"Charles Morris")]') ) ) self.ps.test_updates['passed'] = True # Case C7729 - 016 - Admin | Change a course ecosystem @pytest.mark.skipif(str(7729) not in TESTS, reason='Excluded') def test_admin_change_a_course_ecosystem_7729(self): """Change a course ecosystem. Steps: Go to Tutor Click on the 'Login' button Enter the admin user account in the username and password text boxes Click on the 'Sign in' button Click on the 'Admin' button from the user menu Open the drop down menu by clicking 'Course Organization' Click the 'Courses' option Click the 'Edit' link for the desired course Click on the 'Course content' tab Select a different option in the 'Ecosystem' drop down menu Click the 'Submit' button Expected Result: Course ecosystem change is put on a queue """ self.ps.test_updates['name'] = 'cc1.10.016' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.016', '7729' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Admin' ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Course Organization') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Courses') ) ).click() self.admin.page.wait_for_page_load() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Edit') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Course content') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.ID, 'ecosystem_id') ) ).send_keys('1' + Keys.ENTER) # self.admin.wait.until( # expect.visibility_of_element_located( # (By.XPATH, '//select[@id="ecosystem_id"]//option[1]') # ) # ).click() self.admin.driver.find_element( By.XPATH, '//div[@id="content"]//input[@type="submit"]' ).click() self.admin.sleep(1) self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"alert-info")]' ) self.ps.test_updates['passed'] = True # Case C7730 - 017 - Admin | Change multiple course ecosystems in bulk @pytest.mark.skipif(str(7730) not in TESTS, reason='Excluded') def test_admin_change_multiple_course_ecosystems_in_bulk_7730(self): """Change multiple course ecosystems in bulk. Steps: Go to Tutor Click on the 'Login' button Enter the admin user account in the username and password text boxes Click on the 'Sign in' button Click on the 'Admin' button from the user menu Open the drop down menu by clicking 'Course Organization' Click the 'Courses' option Check the checkboxes next to selected courses Select an option in the 'Select an ecosystem' drop down menu Click the 'Set Ecosystem' button Expected Result: Course ecosystem change is put on a queue """ self.ps.test_updates['name'] = 'cc1.10.017' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.017', '7730' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.teacher.driver.find_element( By.LINK_TEXT, 'Admin' ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Course Organization') ) ).click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Courses') ) ).click() self.admin.page.wait_for_page_load() self.admin.wait.until( expect.visibility_of_element_located( (By.ID, 'courses_select_all') ) ).click() # click the checkmarks for two courses courses = self.admin.driver.find_elements( By.XPATH, '//input[@class="course_id_select"]') course_1 = courses[0] self.admin.driver.execute_script( 'return arguments[0].scrollIntoView();', course_1) self.admin.driver.execute_script('window.scrollBy(0, -120);') course_1.click() self.admin.sleep(0.5) course_2 = courses[1] self.admin.driver.execute_script( 'return arguments[0].scrollIntoView();', course_2) self.admin.driver.execute_script('window.scrollBy(0, -120);') course_2.click() self.admin.sleep(0.5) # scroll to bottom and set bulk ecosystems self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.wait.until( expect.visibility_of_element_located( (By.ID, 'ecosystem_id') ) ).send_keys('1' + Keys.ENTER) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"alert-info")]') ) ) self.ps.test_updates['passed'] = True # Case C7731 - 018 - Teacher | Receive a notice when students register @pytest.mark.skipif(str(7731) not in TESTS, reason='Excluded') def test_teacher_receive_a_notice_when_students_register_7731(self): """Receive a notice when students register. Steps: Expected Result: """ self.ps.test_updates['name'] = 'cc1.10.018' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.10', 'cc1.10.018', '7731' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True
class TestContractControls(unittest.TestCase): """T1.35 - Contract Controls.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: self.admin = Admin(use_env_vars=True, ) self.admin.login() # make sure there are no new terms to accept try: self.admin.driver.find_element(By.ID, 'i_agree').click() except NoSuchElementException: pass try: self.admin.driver.find_element(By.ID, 'agreement_submit').click() except NoSuchElementException: pass # go to admin console self.wait = WebDriverWait(self.admin.driver, 15) self.admin.open_user_menu() self.admin.wait.until( expect.element_to_be_clickable((By.LINK_TEXT, 'Admin'))).click() self.admin.page.wait_for_page_load() self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Legal")]').click() def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.admin.driver.session_id), **self.ps.test_updates) try: self.admin.delete() except: pass # Case C8228 - 001 - Admin | Add a new contract @pytest.mark.skipif(str(8228) not in TESTS, reason='Excluded') def test_admin_add_a_new_contract_8228(self): """Add a new contract. Steps: Click on the 'Terms' option Click on the "New Contract" Link Enter information into the Name, Title, and Content text boxes Click on the 'Create contract' button Expected Result: Contract is created as a draft. User is shown the contract they just made, and has options on what to do with it next """ self.ps.test_updates['name'] = 't1.35.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.001', '8228'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click( ) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]'))).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_001') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_001') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_001') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.driver.find_element( By.XPATH, '//h1[contains(text(),"Details")]').click() self.ps.test_updates['passed'] = True ''' # Case C8229 - 002 - Admin | Cancel adding a new contract @pytest.mark.skipif(str(8229) not in TESTS, reason='Excluded') def test_admin_cancel_adding_a_new_contract_8229(self): """Cancel adding a new contract. Steps: Click on the 'Terms' option Click on the "New Contract" Link Enter information into the Name, Title, and Content text boxes Click on the 'Create contract' button Click on the Delete link Expected Result: Contract is deleted. User is taken back to the Contracts page. """ self.ps.test_updates['name'] = 't1.35.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.002', '8229'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]') ) ).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_002') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_002') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_002') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="Delete"]') ) ).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"alert-info")]') contracts = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_002")]') assert(len(contracts) == 0), 'contract not cancled' self.ps.test_updates['passed'] = True ''' # Case C8230 - 003 - Admin | Publish a draft contract @pytest.mark.skipif(str(8230) not in TESTS, reason='Excluded') def test_admin_publish_a_draft_contract_8230(self): """Publish a draft contract. Steps: Click on the 'Terms' option Create a draft contract and return to contract list Click on the draft contract Click on the Publish link Click ok Expected Result: Draft contract is published """ self.ps.test_updates['name'] = 't1.35.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.003', '8230'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click( ) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]'))).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_003') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_003') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_003') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]'))).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_003")]').click() self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Publish")]').click() try: WebDriverWait(self.admin.driver, 3). \ until( expect.alert_is_present(), 'Timed out waiting for alert.' ) alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.ps.test_updates['passed'] = True # Case C8231 - 004 - Admin | Delete a draft contract @pytest.mark.skipif(str(8231) not in TESTS, reason='Excluded') def test_admin_delete_a_draft_contract_8231(self): """Delete a draft contract. Steps: Click on the 'Terms' option Create a draft contract and return to the contract list Click on the draft contract Click on Delete next to chosen draft contract Expected Result: Draft contract is deleted """ self.ps.test_updates['name'] = 't1.35.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.004', '8231'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() contracts_original = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_004")]') self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click( ) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]'))).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_004') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_004') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_004') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]'))).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_004")]').click() self.admin.page.wait_for_page_load() self.admin.sleep(2) self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Delete")]').click() self.admin.sleep(2) try: WebDriverWait(self.admin.driver, 3). \ until( expect.alert_is_present(), 'Timed out waiting for alert.' ) alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.admin.page.wait_for_page_load() contracts = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"test_contract_title_004")]') self.admin.page.wait_for_page_load() assert(len(contracts) == len(contracts_original)), \ 'contract not deleted' self.ps.test_updates['passed'] = True # Case C8232 - 005 - Admin | View a current contract @pytest.mark.skipif(str(8232) not in TESTS, reason='Excluded') def test_admin_view_a_current_contract_8232(self): """View a current contract. Steps: Click on the 'Terms' option Create a contract and then return to contract list Click on chosen contract Expected Result: Displays the information of chosen contract. """ self.ps.test_updates['name'] = 't1.35.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.005', '8232'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"links")]/a[text()="New Contract"]').click( ) self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//h1[text()="New Contract"]'))).click() self.admin.driver.find_element( By.ID, 'contract_name').send_keys('test_contract_name_005') self.admin.driver.find_element( By.ID, 'contract_title').send_keys('test_contract_title_005') self.admin.driver.find_element( By.ID, 'contract_content').send_keys('test_contract_content_005') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="List"]'))).click() self.admin.driver.find_element( By.XPATH, '//li//a[contains(text(),"test_contract_title_005")]').click() self.admin.driver.find_element( By.XPATH, '//h2[contains(text(),"test_contract_title_005")]') self.ps.test_updates['passed'] = True # Case C8233 - 006 - Admin | Add a new version of a current contract @pytest.mark.skipif(str(8233) not in TESTS, reason='Excluded') def test_admin_add_a_new_version_of_a_current_contract_8233(self): """Add a new version of a current contract. Steps: Click on the 'Terms' option Click on New version next to chosen contract Update information in the Name, Title, and Content text boxes. Click on the 'Create Contract' button Expected Result: New version of contract is saved as a draft. """ self.ps.test_updates['name'] = 't1.35.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.006', '8233'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[text()="New Version"]'))).click() self.admin.driver.find_element(By.ID, 'contract_name').send_keys('NEW_006') self.admin.driver.find_element(By.ID, 'contract_title').send_keys('NEW_006') self.admin.driver.find_element(By.ID, 'contract_content').send_keys('NEW_006') self.admin.driver.find_element( By.XPATH, '//input[@value="Create contract"]').click() self.admin.driver.find_element(By.XPATH, '//h2[contains(text(),"NEW_006")]') self.ps.test_updates['passed'] = True # Case C8234 - 007 - Admin | View a contract's signatories @pytest.mark.skipif(str(8234) not in TESTS, reason='Excluded') def test_admin_view_a_contracts_signatures_8234(self): """View a contract's signatories. Steps: Click on the 'Terms' option Click on Signatures next to chosen draft contract Expected Result: Displays list of signatures for the chosen contract. """ self.ps.test_updates['name'] = 't1.35.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.007', '8234'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() wait = WebDriverWait(self.admin.driver, 45) self.admin.driver.find_element(By.XPATH, '//a[text()="Signatures"]').click() wait.until( expect.element_to_be_clickable( (By.XPATH, '//div[contains(@class,"signature_index")]'))) self.ps.test_updates['passed'] = True # Case C8235 - 008 - Admin | Terminate a signatory's contract @pytest.mark.skipif(str(8235) not in TESTS, reason='Excluded') def test_admin_terminate_a_signnatorys_contract_8235(self): """Terminate a signatory's contract. Steps: Click on the 'Terms' option Click on Signatures next to chosen draft contract Click on Terminate next to chosen user Click on the 'ok' button Expected Result: Selected user's signing of contract is terminated. """ self.ps.test_updates['name'] = 't1.35.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.008', '8235'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Terms")]'))).click() self.admin.driver.find_element(By.XPATH, '//a[text()="Signatures"]').click() # is it okay to just terminate some random person's signature wait = WebDriverWait(self.admin.driver, 45) wait.until( expect.element_to_be_clickable( (By.XPATH, '//td//a[contains(text(),"Terminate")]'))).click() try: WebDriverWait(self.admin.driver, 3). \ until(expect.alert_is_present(), 'Timed out waiting for PA creation ' + 'confirmation popup to appear.') alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') self.ps.test_updates['passed'] = True # Case C8236 - 009 - Admin | Add a targeted contract @pytest.mark.skipif(str(8236) not in TESTS, reason='Excluded') def test_admin_add_a_targeted_contract_8236(self): """Add a targeted contract. Steps: Click on the 'Targeted Contracts' option Click on the 'Add Target Contract' button Click the 'Submit' button Expected Result: User taken back to Targeted contracts page. New Targeted Contract is added """ self.ps.test_updates['name'] = 't1.35.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.009', '8236'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Targeted Contracts")]'))).click() orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') self.admin.driver.find_element( By.XPATH, '//a[text()="Add Targeted Contract"]').click() self.admin.driver.find_element(By.XPATH, '//input[@value="Submit"]').click() end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') assert(len(orig_contracts) == len(end_contracts)-1), \ 'targeted contract not added' self.ps.test_updates['passed'] = True # Case C8237 - 010 - Admin | Delete a targeted contract @pytest.mark.skipif(str(8237) not in TESTS, reason='Excluded') def test_admin_delete_a_targeted_contract_8237(self): """Delete a targeted contract. Steps: Click on the user's name in the top right corner to open drop down menu Click on the 'Admin' option of the drop down menu Click on 'Legal' on the bar across the top to open drop down menu Click on the 'Targeted Contracts' option Create a targeted contract and return to the list of targed contracts Click on delete next to chosen contract Click on the 'ok' button Expected Result: Targeted contract is deleted """ self.ps.test_updates['name'] = 't1.35.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.010', '8237'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Targeted Contracts")]'))).click() orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') # create contract self.admin.driver.find_element( By.XPATH, '//a[text()="Add Targeted Contract"]').click() self.admin.driver.find_element(By.XPATH, '//input[@value="Submit"]').click() # delete contract deletes = self.admin.driver.find_elements( By.XPATH, '//a[contains(text(),"delete")]') deletes[-1].click() try: WebDriverWait(self.admin.driver, 3).until(expect.alert_is_present(), 'Timed out waiting for alert.') alert = self.admin.driver.switch_to_alert() alert.accept() print('alert accepted') except TimeoutException: print('no alert') end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr') assert(len(orig_contracts) == len(end_contracts)), \ 'targeted contract not added' self.ps.test_updates['passed'] = True '''
class TestCourseMaintenance(unittest.TestCase): """T1.57 - Course Maintenance.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() self.admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.admin.login() self.admin.goto_admin_control() self.admin.sleep(5) def tearDown(self): """Test destructor.""" self.ps.update_job(job_id=str(self.admin.driver.session_id), **self.ps.test_updates) try: self.admin.delete() except: pass # Case C8311 - 001 - Admin | Import courses from Salesforece @pytest.mark.skipif(str(8311) not in TESTS, reason='Excluded') def test_admin_import_courses_from_salesforce_8311(self): """Import courses from Salesforce. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on the Import Courses button Expected Result: """ self.ps.test_updates['name'] = 't1.57.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.001', '8311'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8312 - 002 - Admin | Update Salesforce Staistics @pytest.mark.skipif(str(8312) not in TESTS, reason='Excluded') def test_admin_update_salesforce_statistice_8312(self): """Update Salesforce statistics. Steps: Click on the user menu Click on the Admin option Click on Salesforce on the header Click on Update Salesforce Expected Result: """ self.ps.test_updates['name'] = 't1.57.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.002', '8312'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8313 - 003 - Admin | Exclude assesments from all courses @pytest.mark.skipif(str(8313) not in TESTS, reason='Excluded') def test_admin_exclude_assesments_from_all_courses_8313(self): """Exclude assesments from all courses. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.57.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.003', '8313'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) self.ps.test_updates['passed'] = True # Case C8314 - 004 - Admin | Add a system notification @pytest.mark.skipif(str(8314) not in TESTS, reason='Excluded') def test_admin_add_a_system_notification_8314(self): """Add a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Enter a notification into the New Notification text box Click on the Add button Expected Result: A system notification is added """ self.ps.test_updates['name'] = 't1.57.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.004', '8314'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//input[@id='new_message']").send_keys('automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True break # Case C8315 - 005 - Admin | Delete a system notification @pytest.mark.skipif(str(8315) not in TESTS, reason='Excluded') def test_admin_delete_a_system_notification_8315(self): """Delete a system notification. Steps: Click on the user menu Click on the Admin option Click on System Setting on the header Click on the Notifications option Click on the Remove button next to a notification Click OK on the dialouge box Expected Result: A system notification is deleted """ self.ps.test_updates['name'] = 't1.57.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.57', 't1.57.005', '8315'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'System Setting'))).click() self.admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Notifications'))).click() self.admin.sleep(5) self.admin.find( By.XPATH, "//input[@id='new_message']").send_keys('automated test') self.admin.find(By.XPATH, "//input[@class='btn btn-default']").click() self.admin.sleep(5) notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for index, n in enumerate(notif): if n.text.find('automated test') >= 0: self.admin.driver.find_elements_by_xpath( "//a[@class='btn btn-warning']")[index].click() self.admin.driver.switch_to_alert().accept() break deleted = True notif = self.admin.driver.find_elements_by_xpath( "//div[@class='col-xs-12']") for n in notif: if n.text.find('automated test') >= 0: deleted = False break if deleted: self.ps.test_updates['passed'] = True
class TestTutorAdmin(unittest.TestCase): """Tutor | Teacher""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.admin = Admin( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) else: self.admin = Admin( use_env_vars=True ) def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job( job_id=str(self.teacher.driver.session_id), **self.ps.test_updates ) try: self.admin.delete() except: pass @pytest.mark.skipif(str(162255) not in TESTS, reason='Excluded') def test_admin_change_course_start_end_dates_162255(self): """ Log in as an Admin Go to the course management page Edit a course Change the term and course year Click Save ***Start and end dates should reflect the new term's timeframe*** Edit a course Change the Starts at date and Ends at date Click Save Expected Result: ***Start and end dates are changed*** https://trello.com/c/YuvX7DN0/25-admin-change-course-start-end-dates """ self.ps.test_updates['name'] = 'tutor_course_settings_admin_162255' + \ inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['tutor', 'course_settings', 'admin', '162255'] self.ps.test_updates['passed'] = False # go to courses admin page directly and log in URL = str(os.getenv('SERVER_URL')) + '/admin/courses' self.admin.login(url=URL) # search 'preview' in the search bar self.admin.find(By.CSS_SELECTOR, "#search-courses").send_keys('preview\n') self.admin.page.wait_for_page_load() pages = self.admin.find_all(By.CSS_SELECTOR, ".pagination>a") # go to very last page self.admin.scroll_to(pages[-2]) self.admin.sleep(1) pages[-2].click() # click on Edit button for very last course edit = self.admin.find_all(By.XPATH, ".//*[contains(text(),'Edit')]") self.admin.scroll_to(edit[-1]) edit[-1].click() # change year field by adding 1 yearfield = self.admin.find(By.CSS_SELECTOR, "#course_year") year = yearfield.get_attribute('value') newyear = str(int(year) + 1) yearfield.send_keys(len(year) * Keys.DELETE) yearfield.send_keys(newyear) # change start date and end date oldstartdatefield = self.admin.find(By.CSS_SELECTOR, "#course_starts_at") oldenddatefield = self.admin.find(By.CSS_SELECTOR, "#course_ends_at") # get start date and end date values oldstartdate = oldstartdatefield.get_attribute('value') oldenddate = oldenddatefield.get_attribute('value') change = datetime.timedelta(days=400) # converts start date and end date values into datetime objects and adds the change newstartdate = datetime.datetime.strptime( oldstartdate, '%Y-%m-%d %X %Z') + change # converts into a string format accepted by the form oldstartdatefield.send_keys( datetime.datetime.strftime( newstartdate, '%Y/%m/%d %X' )[:-3] ) # converts start date and end date values into datetime objects and adds change ( 400 days) newenddate = datetime.datetime.strptime( oldenddate, '%Y-%m-%d %X %Z') + change # converts into a string format accepted by teh form # newenddate = datetime.datetime.strftime(newenddate1, '%Y/%m/%d %X')[:-3] oldenddatefield.send_keys( datetime.datetime.strftime( newenddate, '%Y/%m/%d %X')[:-3] ) # saves changes self.admin.sleep(1) self.admin.find(By.CSS_SELECTOR, "#edit-save").click() self.admin.sleep(1) # updated start date and end date fields, get their values updatedstartdate = self.admin.find( By.CSS_SELECTOR, "#course_starts_at").get_attribute('value') updatedstartdatetime = datetime.datetime.strptime( updatedstartdate, '%Y-%m-%d %X %Z' ) updatedenddate = self.admin.find( By.CSS_SELECTOR, "#course_ends_at").get_attribute('value') updatedenddatetime = datetime.datetime.strptime( updatedenddate, '%Y-%m-%d %X %Z' ) # assert that the datetime objects I put into it are the ones in the updated field assert(newstartdate.isocalendar() == updatedstartdatetime.isocalendar()) assert(newenddate.isocalendar() == updatedenddatetime.isocalendar()) # change start date and end date to what it was yearfield = self.admin.find(By.CSS_SELECTOR, "#course_year") yearfield.send_keys(len(year) * Keys.DELETE) yearfield.send_keys(year) startdatefield = self.admin.find(By.CSS_SELECTOR, "#course_starts_at") startdatefield.send_keys(datetime.datetime.strftime( datetime.datetime.strptime(oldstartdate, '%Y-%m-%d %X %Z'), '%Y/%m/%d %X')[:-3] ) enddatefield = self.admin.find(By.CSS_SELECTOR, "#course_ends_at") enddatefield.send_keys(datetime.datetime.strftime( datetime.datetime.strptime(oldenddate, '%Y-%m-%d %X %Z'), '%Y/%m/%d %X')[:-3] ) self.admin.find(By.CSS_SELECTOR, "#edit-save").click() self.ps.test_updates['passed'] = True @pytest.mark.skipif(str(162256) not in TESTS, reason='Excluded') def test_notification_and_faulty_url_162256(self): """ Go to tutor qa Log in as admin Click "Admin" from the user menu Click "System Setting" Click "Notifications" Enter a new notification into the text box Click "Add" Log out of admin account Log in as a teacher ***An orange header with the notification pops up when you sign in*** Go to a fake url page to test if styled error page is displayed Expected result: ***a styled error page is displayed*** Corresponding test case: T2.18 001, 030 """ self.ps.test_updates['name'] = 'tutor_system_settings_admin_162256' + \ inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['tutor', 'system_settings', 'admin', '162256'] self.ps.test_updates['passed'] = False # go to admin instance self.admin.login(url=os.getenv('SERVER_URL') + '/admin') # go to system settings, then notifications, then set a notification self.admin.find(By.XPATH,".//*[contains(text(),'System Setting')]").click() self.admin.find(By.CSS_SELECTOR,"a[href*='notification']").click() self.admin.find(By.CSS_SELECTOR, "#message").send_keys('test_notification') self.admin.find(By.CSS_SELECTOR, ".btn.btn-default").click() # logout of admin self.admin.find(By.XPATH,".//*[contains(text(),'admin')]").click() self.admin.find(By.CSS_SELECTOR, 'a[href*="logout"]').click() # log into teacher account self.admin.login(username=os.getenv('TEACHER_USER'), password=os.getenv('TEACHER_PASSWORD')) self.admin.find(By.CSS_SELECTOR, '.my-courses-item-title>a').click() # if popup asking how you will be using Tutor shows up try: self.admin.find(By.XPATH, './/*[contains(text(),"I don’t know yet")]') except: pass # checks if notification is there self.admin.wait.until( expect.visibility_of_element_located(( By.XPATH, '//div[contains(@class,"notifications-bar")]' + '//span[text()="test_notification"]' )) ) self.admin.find( By.XPATH, '//div[contains(@class,"notifications-bar")]' + '//span[text()="test_notification"]' ) # log out of teacher self.admin.logout() # log into admin self.admin.login(url=os.getenv('SERVER_URL') + '/admin') self.admin.find(By.XPATH, '//a[text()="System Setting"]').click() self.admin.find(By.XPATH, '//a[text()="Notifications"]').click() # remove general notification self.admin.find(By.XPATH, '//a[text()="Remove"]').click() self.admin.driver.switch_to_alert().accept() # go to invalid website self.admin.get(os.getenv('SERVER_URL') + '/not_a_Real_page') # confirm styling of webpage self.admin.find(By.CSS_SELECTOR, '.invalid-page') self.ps.test_updates['passed'] = True