def test_admin_add_coinstructors_to_a_course_7770(self): """Add co-instructors to a course. Steps: Log into Tutor as an admin From the user menu, select 'Admin' From the 'Course Organization' menu, select 'Courses' In the Courses table, find the correct course and click the 'Edit' button on the right side of that row Click on the 'Teachers' tab In the search box, enter the teacher's name or username Select the teacher in the list below the search bar or hit the down arrow followed by the enter/return key Expected Result: Co-instructor is linked to the affected course """ self.ps.test_updates['name'] = 'cc1.01.020' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.020', '7770'] self.ps.test_updates['passed'] = False # Test steps and verification assertions if not LOCAL_RUN: admin = Admin(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: admin = Admin(use_env_vars=True) admin.login() admin.open_user_menu() admin.find(By.CSS_SELECTOR, '[href*=admin]').click() admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Course Organization'))).click() admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Courses'))).click() admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Edit'))).click() admin.wait.until( expect.visibility_of_element_located( (By.PARTIAL_LINK_TEXT, 'Teachers'))).click() admin.wait.until( expect.visibility_of_element_located( (By.ID, 'course_teacher'))).send_keys('teacher0') element = admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//ul[contains(@class,"ui-autocomplete")]' + '//li[contains(text(),"(teacher0")]'))) teacher_name = element.text.split(' (')[0] element.click() # check that the teacher has been added to the table print(teacher_name) admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//td[contains(text(),"' + teacher_name + '")]'))) self.ps.test_updates['passed'] = True
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 setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.teacher = Teacher( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.student = Student( use_env_vars=True, existing_driver=self.teacher.driver, 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 ) else: self.teacher = Teacher( use_env_vars=True ) self.student = Student( use_env_vars=True, existing_driver=self.teacher.driver, ) self.admin = Admin( use_env_vars=True, existing_driver=self.teacher.driver, )
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 ) self.content = ContentQA( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) else: self.admin = Admin( use_env_vars=True ) self.content = ContentQA( use_env_vars=True, existing_driver=self.admin.driver ) self.wait = WebDriverWait(self.admin.driver, Assignment.WAIT_TIME) self.admin.login() self.wait.sleep(2) self.admin.goto_admin_control()
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 )
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 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.admin.login() self.admin.goto_admin_control()
class TestStaxingAdmin(unittest.TestCase): """Staxing case tests.""" def setUp(self): """Pretest settings.""" self.admin = Admin(use_env_vars=True, driver_type=DRIVER) self.admin.set_window_size(height=700, width=1200) def tearDown(self): """Test destructor.""" try: self.admin.delete() except Exception: pass
class TestStaxingAdmin(unittest.TestCase): """Staxing case tests.""" def setUp(self): """Pretest settings.""" self.admin = Admin(use_env_vars=True) self.admin.set_window_size(height=700, width=1200) def tearDown(self): """Test destructor.""" try: self.admin.driver.quit() except: pass
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.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(),"Users")]').click()
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.content = ContentQA( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.student = Student( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.teacher = Teacher( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities )
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 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.content = ContentQA(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.student = Student(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.teacher = Teacher(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities)
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)
class TestGenerateReports(unittest.TestCase): """T1.68 - Generate Reports.""" 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() 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 C8361 - 001 - Admin | Export research data to OwnCloud Research @pytest.mark.skipif(str(8361) not in TESTS, reason='Excluded') def test_admin_export_research_data_to_own_cloud_research_8361(self): """Export research data to OwnCloud Research. Steps: Open the user menu by clicking on the user's name Click on the 'Admin' button Click the 'Research Data' button Click on the 'Export Data' button Expected Result: The page is reloaded and a confirmation message is displayed. """ self.ps.test_updates['name'] = 't1.68.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.68', 't1.68.001', '8361'] self.ps.test_updates['passed'] = False # Test steps and verification assertions 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(),"Research Data")]').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Export Data"]').click() self.admin.driver.find_element( By.XPATH, '//div[contains(@class,"alert-info")]') 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 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'
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.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(),"Users")]' ).click()
def test_admin_import_content_into_tutor_7604(self): """Import content into Tutor. Steps: Select Customer Analyst from the dropdown menu on the name Click on Ecosystems in the header Click "Download Manifest" for the desired course Scroll down and click Import a new Ecosystem button. Click "Choose File" Select the downloaded file In comment section add today's date and your name. Eg: 2016-03-03 Kajal Click on the button Import Now wait for at most 5 mins. Expected Result: The message "Ecosystem import job queued" appears at the top """ self.ps.test_updates['name'] = 'cc1.03.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.03', 'cc1.03.002', '7604' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions admin = Admin( existing_driver=self.content.driver, username=os.getenv('ADMIN_USER'), password=os.getenv('ADMIN_PASSWORD'), pasta_user=self.ps, capabilities=self.desired_capabilities, ) admin.login() admin.open_user_menu() admin.driver.find_element( By.LINK_TEXT, "Content Analyst" ).click() admin.page.wait_for_page_load() admin.driver.find_element( By.LINK_TEXT, "Ecosystems" ).click() # download a manifest to test with admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, "Download Manifest") ) ).click() # import a new ecosystem admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") admin.driver.find_element( By.LINK_TEXT, "Import a new Ecosystem" ).click() # find a downloaded manifest home = os.getenv("HOME") files = os.listdir(home + '/Downloads') file = '' for i in range(len(files)): if (files[i][-4:] == '.yml'): file = files[i] break else: if i == len(files)-1: print('no .yml file found in downloads') raise Exception admin.wait.until( expect.visibility_of_element_located( (By.ID, "ecosystem_manifest") ) ).send_keys(home + '/Downloads/' + file) admin.wait.until( expect.visibility_of_element_located( (By.ID, "ecosystem_comments") ) ).send_keys(str(datetime.date.today()) + ' automated-admin') admin.driver.find_element( By.XPATH, "//input[@type='submit']" ).click() admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"alert-info")]') ) ) admin.delete() self.ps.test_updates['passed'] = True
class TestGuideMonitorSupportAndTrainUsers(unittest.TestCase): """T2.18 - Guide, Monitor, Support, and Train Users.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.teacher = Teacher( use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.student = Student( use_env_vars=True, existing_driver=self.teacher.driver, 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 ) else: self.teacher = Teacher( use_env_vars=True ) self.student = Student( use_env_vars=True, existing_driver=self.teacher.driver, ) self.admin = Admin( use_env_vars=True, 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 ) try: self.student.driver = None self.admin.driver = None self.teacher.delete() except: pass # C14752 - 001 - User | In-app Notification of downtime @pytest.mark.skipif(str(14752) not in TESTS, reason='Excluded') def test_user_inapp_notification_of_downtime_14752(self): """In-app Notification of downtime. Steps: Go to Tutor 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 Log in as teacher01 Expected Result: An orange header with the notification pops up when you sign in """ self.ps.test_updates['name'] = 't2.18.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.001', '14752'] self.ps.test_updates['passed'] = False # Test steps and verification assertions # create notification self.admin.login() self.admin.open_user_menu() self.admin.find(By.LINK_TEXT, 'Admin').click() self.admin.find(By.XPATH, '//a[text()="System Setting"]').click() self.admin.find(By.XPATH, '//a[text()="Notifications"]').click() self.admin.find(By.ID, 'message') \ .send_keys("test_notification") self.admin.find(By.XPATH, '//input[@value="Add"]').click() self.admin.find(By.XPATH, '//a[text()="admin "]').click() self.admin.find(By.XPATH, '//a[text()="Sign out!"]').click() # check that the notification appears self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//div[contains(@class,"notifications-bar")]' + '//span[text()="test_notification"]' )) ) self.teacher.find( By.XPATH, '//div[contains(@class,"notifications-bar")]' + '//span[text()="test_notification"]' ) self.teacher.logout() # remove notification self.admin.login() self.admin.open_user_menu() self.admin.find(By.LINK_TEXT, 'Admin').click() self.admin.find(By.XPATH, '//a[text()="System Setting"]').click() self.admin.find(By.XPATH, '//a[text()="Notifications"]').click() self.admin.find(By.XPATH, '//a[text()="Remove"]').click() self.admin.driver.switch_to_alert().accept() self.ps.test_updates['passed'] = True # C14751 - 002 - Teacher | Directed to a "No Courses" page when not in any # courses yet @pytest.mark.skipif(str(14751) not in TESTS, reason='Excluded') def test_teacher_directed_to_a_no_courses_page_when_not_in_any_14751(self): """Directed to a "No Courses" page when not in any courses yet. Steps: Go to Tutor Sign in as a teacher without a course Expected Result: The message "We cannot find an OpenStax course associated with your account" displays with help links below. """ self.ps.test_updates['name'] = 't2.18.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.002', '14751'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login( username='******', password=os.getenv('CONTENT_PASSWORD') ) self.teacher.page.wait_for_page_load() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//p[contains(text(),"cannot find an ' + 'OpenStax course associated")]' )) ) self.ps.test_updates['passed'] = True # C58279 - 003 - Teacher | View "Getting Started with Tutor" Guide @pytest.mark.skipif(str(58279) not in TESTS, reason='Excluded') def test_teacher_view_getting_started_with_tutor_guide_58279(self): """View "Getting Started with Tutor" Guide. Steps: Click "Tutor Instructors. Get help" Expected Result: Tutor Help Center opens in another tab with the Getting Started guide """ self.ps.test_updates['name'] = 't2.18.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.003', '58279'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('getting started') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() raise NotImplementedError(inspect.currentframe().f_code.co_name) self.teacher.find(By.XPATH, '//h1[contains(text(),"Getting Started")]') assert('articles' in self.teacher.current_url()), 'not at article' self.ps.test_updates['passed'] = True # C58280 - 004 - Teacher | Access Tutor Help Center after registering for # a course @pytest.mark.skipif(str(58280) not in TESTS, reason='Excluded') def test_teacher_access_tutor_help_center_after_registering_58280(self): """Access Tutor Help Center after registering for a course. Steps: Go to Tutor Sign in as teacher01 Click on a Tutor course if the user is in more than one Click "Get Help" from the user menu in the upper right corner of the screen Expected Result: The user is presented with the Tutor Help Center """ self.ps.test_updates['name'] = 't2.18.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.004', '58280'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find( By.XPATH, '//center[contains(text(),"Tutor Support")]' ) self.ps.test_updates['passed'] = True # C58284 - 005 - User | Submit a question @pytest.mark.skipif(str(58284) not in TESTS, reason='Excluded') def test_user_submit_a_question_58284(self): """Submit a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Expected Result: The user is presented with search results """ self.ps.test_updates['name'] = 't2.18.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.005', '58284'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.ID, 'results') self.teacher.find(By.CSS_SELECTOR, 'div.article') self.ps.test_updates['passed'] = True # 58352 - 006 - User | View "Contact Us" button after submitting a # question @pytest.mark.skipif(str(58352) not in TESTS, reason='Excluded') def test_user_view_contact_us_button_after_submitting_question_58352(self): """View "Contact Us" button after submitting a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Scroll to the bottom of the screen Expected Result: "Contact Us" button exists """ self.ps.test_updates['name'] = 't2.18.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.006', '58352'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.XPATH, '//a[contains(text(),"Email Us")]') self.ps.test_updates['passed'] = True # C58288 - 007 - User | View an article after submitting a question @pytest.mark.skipif(str(58288) not in TESTS, reason='Excluded') def test_user_view_an_article_after_submitting_a_question_58288(self): """View an article after submitting a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Expected Result: The user is presented with an article containing answer to the question """ self.ps.test_updates['name'] = 't2.18.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.007', '58288'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, 'div.article a').click() self.teacher.find(By.ID, 'articleContainer') assert('articles' in self.teacher.current_url()), 'not at article' self.ps.test_updates['passed'] = True # C58313 - 008 - User | Indicate that the article was helpful @pytest.mark.skipif(str(58313) not in TESTS, reason='Excluded') def test_user_indicate_that_the_article_was_helpful_58313(self): """Indicate that the article was helpful. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "Yes" Expected Result: A message that says "Thanks for your feedback!" is displayed """ self.ps.test_updates['name'] = 't2.18.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.008', '58313'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.CSS_SELECTOR, '#feedback [value="Yes"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//div[contains(text(),"Thanks for your feedback!")]' )) ) self.ps.test_updates['passed'] = True # C58314 - 009 - User | Negative feedback renders a feedback popup box @pytest.mark.skipif(str(58314) not in TESTS, reason='Excluded') def test_user_negative_feedback_renders_feedback_popup_box_58314(self): """Negative feedback renders a feedback popup box. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Expected Result: The user is presented with a popup box that allows them to input feedback """ self.ps.test_updates['name'] = 't2.18.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.009', '58314'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.ID, 'feedbackDialog' )) ) self.ps.test_updates['passed'] = True # C58315 - 010 - User | Submit feedback for an article @pytest.mark.skipif(str(58315) not in TESTS, reason='Excluded') def test_user_submit_feedback_for_an_article_58315(self): """Submit feedback for an article. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Enter feedback into the box that pops up Click "Submit" Expected Result: A message that says "Thanks for your feedback!" is displayed in the box """ self.ps.test_updates['name'] = 't2.18.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.010', '58315'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.ID, 'feedbackDialog' )) ) self.teacher.find(By.ID, 'feedbackTextArea') \ .send_keys('qa automated test feedback') self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//p[text()="Thanks for your feedback!"]' )) ) self.ps.test_updates['passed'] = True # C58322 - 011 - User | Close window after submitting feedback for an # article @pytest.mark.skipif(str(58322) not in TESTS, reason='Excluded') def test_user_close_window_after_submitting_feedback_for_58322(self): """Close window after submitting feedback for an article. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Enter feedback into the box that pops up Click "Submit" Click "Close window" Expected Result: The popup box closes and the message "Thanks for your feedback" displays beneath "Feedback" """ self.ps.test_updates['name'] = 't2.18.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.011', '58322'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.ID, 'feedbackDialog' )) ) self.teacher.find(By.ID, 'feedbackTextArea') \ .send_keys('qa automated test feedback') self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//a[text()="close window"]' )) ).click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//div[text()="Thanks for your feedback!"]' )) ) self.ps.test_updates['passed'] = True # C58316 - 012 - User | Cancel feedback @pytest.mark.skipif(str(58316) not in TESTS, reason='Excluded') def test_user_cancel_feedback_before_making_changes_58316(self): """Cancel feedback. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" [optional] Enter feedback into the text box Click "Cancel" Expected Result: The popup box closes """ self.ps.test_updates['name'] = 't2.18.012' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.012', '58316'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.ID, 'feedbackDialog' )) ) self.teacher.find(By.CSS_SELECTOR, '[value="Cancel"]').click() with self.assertRaises(ElementNotVisibleException): self.teacher.find(By.ID, 'feedbackDialog').click() self.ps.test_updates['passed'] = True # C58318 - 013 - User | View related articles @pytest.mark.skipif(str(58318) not in TESTS, reason='Excluded') def test_user_view_related_articles_58318(self): """View related articles. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Related Articles" Click on one of the articles (if any) Expected Result: The user is presented with the related article """ self.ps.test_updates['name'] = 't2.18.013' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.013', '58318'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() self.teacher.find(By.CSS_SELECTOR, '.article a').click() assert('articles' in self.teacher.current_url()), 'not at the article' self.teacher.find(By.XPATH, '//h2[text()="Related Articles"]') self.ps.test_updates['passed'] = True # C58319 - 014 - User | Submit a question to Customer Support @pytest.mark.skipif(str(58319) not in TESTS, reason='Excluded') def test_user_submit_a_question_to_customer_support_58319(self): """Submit a question to Customer Support. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine CLick "Search" or press enter Click on a search result Scroll to the bottom of the page CLick "Contact Us" Fill out the required fields Enter "Submit" Expected Result: The message "Thank you for your message! We'll be back to you within one business day" is displayed """ self.ps.test_updates['name'] = 't2.18.014' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.014', '58319'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click() self.teacher.open_user_menu() self.teacher.find(By.LINK_TEXT, 'Get Help').click() self.teacher.sleep(1) window_with_help = self.teacher.driver.window_handles[1] self.teacher.driver.switch_to_window(window_with_help) self.teacher.find(By.ID, 'searchAskInput') \ .send_keys('question') self.teacher.find(By.ID, 'searchAskButton').click() self.teacher.page.wait_for_page_load() contact = self.teacher.find( By.XPATH, '//a[contains(text(),"Email Us")]' ) Assignment.scroll_to(self.teacher.driver, contact) contact.click() self.teacher.page.wait_for_page_load() self.teacher.find( By.XPATH, '//input[contains(@name,"contactUsForm:firstName")]' ).send_keys('qa_test_first_name') self.teacher.find( By.XPATH, '//input[contains(@name,"contactUsForm:lastName")]' ).send_keys('qa_test_last_name') self.teacher.find( By.XPATH, '//input[contains(@name,"contactUsForm:email")]' ).send_keys('*****@*****.**') self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click() self.teacher.wait.until( expect.visibility_of_element_located(( By.XPATH, '//p[contains(text(),"Thank you for your message!")]' )) ) self.ps.test_updates['passed'] = True # C14755 - 015 - Teacher | View guided tutorials of Tutor @pytest.mark.skipif(str(14755) not in TESTS, reason='Excluded') def test_teacher_view_guided_tutorials_of_tutor_14755(self): """View guided tutorials of Tutor. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.18.015' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.015', '14755'] 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 # C14750 - 016 - Student | Directed to a "No Courses" page when not in any # courses yet @pytest.mark.skipif(str(14750) not in TESTS, reason='Excluded') def test_student_directed_to_a_no_courses_page_when_not_in_any_14750(self): """Directed to a "No Courses" page when not in any courses yet. Steps: Go to Tutor Log in as qa_student_37003 Expected Result: The message "We cannot find an OpenStax course associated with your account" displays with help links """ self.ps.test_updates['name'] = 't2.18.016' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.016', '14750'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.login( username='******', password=os.getenv('CONTENT_PASSWORD') ) self.student.page.wait_for_page_load() self.teacher.wait.until( expect.visibility_of_element_located(( By.CSS_SELECTOR, '.panel-body .lead:first-of-type' )) ) self.ps.test_updates['passed'] = True # C58336 - 017 - Student | View "Getting Started with Tutor" Guide @pytest.mark.skipif(str(58336) not in TESTS, reason='Excluded') def test_student_view_getting_started_with_tutor_guide_58336(self): """View "Getting Started with Tutor" Guide. Steps: Click "Tutor Students. Get help" Expected Result: Tutor Help Center opens in another tab with the Getting Started guide """ self.ps.test_updates['name'] = 't2.18.017' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.017', '58336'] 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 # C58337 - 018 - Student | Access Tutor Help Center after registering for a # course @pytest.mark.skipif(str(58337) not in TESTS, reason='Excluded') def test_student_access_tutor_help_center_after_registering_fo_58337(self): """Access Tutor Help Center after registering for a course. Steps: Go to Tutor Sign in as student01 Click on a Tutor course if the user is in more than one Click "Get Help" from the user menu in the upper right corner of the screen Expected Result: The user is presented with the Tutor Help Center """ self.ps.test_updates['name'] = 't2.18.018' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.018', '58337'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.login( username='******', password=os.getenv('CONTENT_PASSWORD') ) self.student.page.wait_for_page_load() self.student.find(By.XPATH, '//a[p[@data-is-beta="true"]]').click() self.student.open_user_menu() self.student.find(By.LINK_TEXT, 'Get Help').click() self.student.sleep(0.5) window_with_help = self.student.driver.window_handles[1] self.student.driver.switch_to_window(window_with_help) self.student.page.wait_for_page_load() self.student.find( By.XPATH, '//center[contains(text(),"Tutor Support")]' ) self.ps.test_updates['passed'] = True ''' # C58338 - 019 - Student | Submit a question @pytest.mark.skipif(str(58338) not in TESTS, reason='Excluded') def test_student_submit_a_question_58338(self): """Submit a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Expected Result: The user is presented with search results """ self.ps.test_updates['name'] = 't2.18.019' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.019', '58338'] 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 # C58353 - 020 - Student | View "Contact Us" button after submitting a # question @pytest.mark.skipif(str(58353) not in TESTS, reason='Excluded') def test_student_view_contact_us_button_after_submitting_quest_58353(self): """View "Contact Us" button after submitting a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Scroll to the bottom of the page Expected Result: "Contact Us" button exists """ self.ps.test_updates['name'] = 't2.18.020' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.020', '58353'] 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 # C58339 - 021 - Student | View an article after submitting a question @pytest.mark.skipif(str(58339) not in TESTS, reason='Excluded') def test_student_view_an_article_after_submitting_a_question_58339(self): """View an article after submitting a question. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Expected Result: The user is presented with an article containing answer to the question """ self.ps.test_updates['name'] = 't2.18.021' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.021', '58339'] 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 # C58340 - 022 - Student | Indicate that the article was helpful @pytest.mark.skipif(str(58340) not in TESTS, reason='Excluded') def test_student_indicate_that_the_article_was_helpful_58340(self): """Indicate that the article was helpful. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "Yes" Expected Result: A message that says "Thanks for your feedback!" is displayed """ self.ps.test_updates['name'] = 't2.18.022' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.022', '58340'] 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 # C58341 - 023 - Student | Negative feedback renders a feedback popup box @pytest.mark.skipif(str(58341) not in TESTS, reason='Excluded') def test_student_negative_feedback_renders_feedback_popup_box_58341(self): """Negative feedback renders a feedback popup box. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Expected Result: The user is presented with a popup box that allows them to input feedback """ self.ps.test_updates['name'] = 't2.18.023' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.023', '58341'] 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 # C58342 - 024 - Student | Submit feedback for an article @pytest.mark.skipif(str(58342) not in TESTS, reason='Excluded') def test_student_submit_feedback_for_an_article_58342(self): """Submit feedback for an article. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Enter feedback into the box that pops up Click "Submit" Expected Result: A message that says "Thanks for your feedback!" is displayed in the box """ self.ps.test_updates['name'] = 't2.18.024' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.024', '58342'] 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 # C58343 - 025 - Student | Close window after submitting feedback for an # article @pytest.mark.skipif(str(58343) not in TESTS, reason='Excluded') def test_student_close_window_after_submitting_feedback_for_58343(self): """Close window after submitting feedback for an article. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" Enter feedback into the box that pops up Click "Submit" Click "Close window" Expected Result: The popup box closes and the message "Thanks for your feedback" displays beneath "Feedback" """ self.ps.test_updates['name'] = 't2.18.025' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.025', '58343'] 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 # C58344 - 026 - Student | Cancel feedback @pytest.mark.skipif(str(58344) not in TESTS, reason='Excluded') def test_student_cancel_feedback_58344(self): """Cancel feedback. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Feedback" Click "No" [optional] Enter feedback into text box Click "Cancel" Expected Result: The popup box closes """ self.ps.test_updates['name'] = 't2.18.026' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.026', '58344'] 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 # C58346 - 027 - Student | View related articles @pytest.mark.skipif(str(58346) not in TESTS, reason='Excluded') def test_student_view_related_articles_58346(self): """View related articles. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to "Related Articles" Click on one of the articles (if any) Expected Result: The user is presented with the related article """ self.ps.test_updates['name'] = 't2.18.027' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.027', '58346'] 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 # C58347 - 028 - Student | Submit a question to Customer Support @pytest.mark.skipif(str(58347) not in TESTS, reason='Excluded') def test_student_submit_a_question_to_customer_support_58347(self): """Submit a question to Customer Support. Steps: Click "Get Help" from the user menu Enter a question or search words into the search engine Click "Search" or press enter Click on a search result Scroll to the bottom of the page Click "Contact Us" Fill out the required fields Enter "Submit" Expected Result: The message "Thank you for your message! We'll be back to you within one business day" is displayed """ self.ps.test_updates['name'] = 't2.18.028' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.028', '58347'] 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 ''' # C58348 - 029 - Student | View guided tutorials of Tutor @pytest.mark.skipif(str(58348) not in TESTS, reason='Excluded') def test_student_view_guided_tutorials_of_tutor_58348(self): """View guided tutorial of Tutor. Steps: Expected Result: """ self.ps.test_updates['name'] = 't2.18.029' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.029', '58348'] 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 # C111250 - 030 - User | Faulty URL shows a styled 404 error page @pytest.mark.skipif(str(111250) not in TESTS, reason='Excluded') def test_user_faulty_url_shows_styled_404_page_111250(self): """Faulty URL shows a styled 404 error page. Steps: go to https://tutor-qa.openstax.org/not_a_real_page Expected Result: A styled error page is displayed """ self.ps.test_updates['name'] = 't2.18.030' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.030', '111250'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.teacher.login() self.teacher.get('https://tutor-qa.openstax.org/not_a_real_page') self.teacher.wait.until( expect.presence_of_element_located(( By.CSS_SELECTOR, '.invalid-page' )) ) self.ps.test_updates['passed'] = True
class TestOpenStaxMetrics(unittest.TestCase): """CC1.15 - OpenStax Metrics.""" 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.admin.driver.session_id), **self.ps.test_updates ) try: self.admin.delete() except: pass # Case C7608 - 001 - Admin | View a report of enrolled students by course @pytest.mark.skipif(str(7608) not in TESTS, reason='Excluded') def test_admin_view_a_report_of_enrolled_students_by_course_7608(self): """View a report of enrolled students by course. 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 'List Students' button for the chosen course Expected Result: List of students for chosen course is displayed """ self.ps.test_updates['name'] = 'cc1.15.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.15', 'cc1.15.001', '7608' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.admin.find( By.LINK_TEXT, 'Admin' ).click() self.admin.page.wait_for_page_load() self.admin.find( By.LINK_TEXT, 'Course Organization' ).click() self.admin.find( By.LINK_TEXT, 'Courses' ).click() self.admin.page.wait_for_page_load() self.admin.find( By.LINK_TEXT, 'List Students' ).click() # assert thaken to correct page self.admin.find( By.XPATH, '//h1[contains(text(),"Students for course")]' ) assert('student' in self.admin.current_url()) self.ps.test_updates['passed'] = True
class TestAccountMaintenance(unittest.TestCase): """T1.37 - Account 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.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(),"Users")]').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 C8247 - 001 - Admin | Search for a username @pytest.mark.skipif(str(8247) not in TESTS, reason='Excluded') def test_admin_search_for_a_username_8247(self): """Search for a username. Steps: Enter a username into the search here text box Click on the 'Search' button Expected Result: A list of users with the search term in their name, or username is displayed. """ self.ps.test_updates['name'] = 't1.37.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.001', '8247'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element(By.ID, 'query').send_keys('Atticus') self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element(By.XPATH, '//td[contains(text(),"Atticus")]') self.ps.test_updates['passed'] = True # Case C8248 - 002 - Admin | Search for a user's name @pytest.mark.skipif(str(8248) not in TESTS, reason='Excluded') def test_admin_search_for_a_users_name_8248(self): """Search for a user's name. 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 'Users' on the bar across the top Enter a user's name into the search here text box Click on the 'Search' button Expected Result: A list of users with the search term in their name, or username is displayed. """ self.ps.test_updates['name'] = 't1.37.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.002', '8248'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element(By.ID, 'query').send_keys('student01') self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element(By.XPATH, '//td[text()="student01"]') self.ps.test_updates['passed'] = True # Case C8249 - 003 - Admin | Create a new user @pytest.mark.skipif(str(8249) not in TESTS, reason='Excluded') def test_admin_create_a_user_8249(self): """Create a new user. Steps: Scroll to the bottom of the page Click on the 'Create user' button Enter account information into: -Username, Password, First name, and Last name text boxes Click on the 'Save' button Expected Result: Takes User back to the Users screen. New user is added. """ self.ps.test_updates['name'] = 't1.37.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.003', '8249'] self.ps.test_updates['passed'] = False # Test steps and verification assertions num = str(randint(0, 999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username'))).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_' + num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # look up account to check that the account was made self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[text()="automated_test_user_' + num + '"]') self.ps.test_updates['passed'] = True # Case C8250 - 004 - Admin | Edit a user @pytest.mark.skipif(str(8250) not in TESTS, reason='Excluded') def test_admin_edit_a_user_8250(self): """Edit a user. Steps: Create a user to edit Enter the user's name into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user Enter new account information into the First name text box Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's information is updated """ self.ps.test_updates['name'] = 't1.37.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.004', '8250'] self.ps.test_updates['passed'] = False # create a user num = str(randint(1000, 1999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username'))).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_' + num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]'))).click() self.admin.driver.find_element(By.ID, 'user_first_name').send_keys('_EDITED') self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[contains(text(),"first_name_' + num + '_EDITED")]') self.ps.test_updates['passed'] = True # Case C8251 - 005 - Admin | Assign elevated permissions @pytest.mark.skipif(str(8251) not in TESTS, reason='Excluded') def test_admin_assign_elevated_permissions_8251(self): """Assign elevated permissions. Steps: Create a user to edit Enter the user's username into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user If check box for chosen permission is not checked, click on check box. Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's permissions are modified. """ self.ps.test_updates['name'] = 't1.37.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.005', '8251'] self.ps.test_updates['passed'] = False # create a user num = str(randint(2000, 2999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username'))).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_' + num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]'))).click() self.admin.driver.find_element(By.ID, 'user_content_analyst').click() self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'Yes'), \ 'permission not elevated ' + element.get_attribute('innerHTML') self.ps.test_updates['passed'] = True # Case C8252 - 006 - Admin | Remove elevated permissions @pytest.mark.skipif(str(8252) not in TESTS, reason='Excluded') def test_admin_remove_elevated_permissions_8252(self): """Remove elevated permissions. Steps: Create a user to edit Enter the user's name into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user If check box for chosen permission is checked, click to uncheck it. Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's permissions are modified. """ self.ps.test_updates['name'] = 't1.37.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.006', '8252'] self.ps.test_updates['passed'] = False # create a user num = str(randint(3000, 3999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username'))).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_' + num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_' + num) self.admin.driver.find_element(By.ID, 'user_content_analyst').click() self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'Yes'), \ 'permission not elevated ' + element.get_attribute('innerHTML') # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]'))).click() self.admin.driver.find_element(By.ID, 'user_content_analyst').click() self.admin.driver.find_element(By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until(expect.element_to_be_clickable( (By.ID, 'query'))).send_keys('automated_test_user_' + num) self.admin.driver.find_element(By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'No'), \ 'permission not elevated ' + element.get_attribute('innerHTML') self.ps.test_updates['passed'] = True # Case C8253 - 007 - Admin | Impersonate a user @pytest.mark.skipif(str(8253) not in TESTS, reason='Excluded') def test_admin_impersonate_a_user_8253(self): """Impersonate a user. Steps: Click on the 'Sign in as' button next to a user Expected Result: Signs in as chosen chosen user. Goes to chosen users initial screen after login (different depending on the user) """ self.ps.test_updates['name'] = 't1.37.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.007', '8253'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element(By.ID, 'query').send_keys('student01') 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(),"Atticus Finch")]'))) self.ps.test_updates['passed'] = True
class TestCNXNavigation(unittest.TestCase): """CC1.05 - CNX Navigation.""" def setUp(self): """Pretest settings.""" self.ps = PastaSauce() self.desired_capabilities['name'] = self.id() if not LOCAL_RUN: self.student = Student(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.admin = Admin(existing_driver=self.student.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: self.student = Student(use_env_vars=True, ) self.admin = Admin( use_env_vars=True, existing_driver=self.student.driver, ) def tearDown(self): """Test destructor.""" if not LOCAL_RUN: self.ps.update_job(job_id=str(self.student.driver.session_id), **self.ps.test_updates) self.admin = None try: self.student.delete() except: pass # Case C7625 - 001 - Student | Log into Concept Coach for a course on CNX @pytest.mark.skipif(str(7625) not in TESTS, reason='Excluded') def test_student_log_into_cc_for_a_course_on_cnx_7625(self): """Log into Concept Coach for a course on CNX. Steps: Go to tutor-qa Click on the 'Login' button Enter the student user account in the username and password text boxes Click on the 'Sign in' button If the user has more than one course, click on a CC course name Expected Result: The student logs into Concept Coach """ self.ps.test_updates['name'] = 'cc1.05.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.05', 'cc1.05.001', '7625'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.get(self.student.url) self.student.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.student.driver.get_window_size()['width'] <= \ self.student.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.student.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]') # check if the menu is collapsed and, if yes, open it if ('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.student.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Log in'))).click() self.student.page.wait_for_page_load() self.student.find(By.ID, 'login_username_or_email').send_keys( self.student.username) self.student.find(By.CSS_SELECTOR, '.primary').click() self.student.find(By.ID, 'login_password').send_keys(self.student.password) self.student.find(By.CSS_SELECTOR, '.primary').click() self.student.page.wait_for_page_load() # check if a password change is required if 'reset your password' in self.student.driver.page_source.lower(): try: self.student.find(By.ID, 'set_password_password') \ .send_keys(self.student.password) self.student.find( By.ID, 'set_password_password_confirmation') \ .send_keys(self.student.password) self.student.find(By.CSS_SELECTOR, '.primary').click() self.student.sleep(1) self.student.find(By.CSS_SELECTOR, '.primary').click() except Exception as e: raise e self.student.page.wait_for_page_load() source = self.student.driver.page_source.lower() print('Reached Terms/Privacy') while 'terms of use' in source or 'privacy policy' in source: self.student.accept_contract() self.student.page.wait_for_page_load() source = self.student.driver.page_source.lower() assert('dashboard' in self.student.current_url()),\ 'Not taken to dashboard: %s' % self.student.current_url() self.student.driver.find_element( By.XPATH, '//p[contains(text(),"OpenStax Concept Coach")]').click() self.student.driver.find_element( By.XPATH, '//div[contains(text(),' + '"You are being redirected to your Concept Coach textbook")]') self.ps.test_updates['passed'] = True ''' # Case C7626 - 002 - Student | Following CC login author links are not seen @pytest.mark.skipif(str(7626) not in TESTS, reason='Excluded') def test_student_following_cc_login_author_links_are_not_seen_7626(self): """Following Concept Coach login author links are not seen. Steps: Go to tutor-qa Click on the 'Login' button Enter the student user account in the username and password text boxes Click on the 'Sign in' button If the user has more than one course, click on a CC course name Expected Result: Author links should not be seen """ self.ps.test_updates['name'] = 'cc1.05.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.05', 'cc1.05.002', '7626' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.login() self.student.driver.find_element( By.XPATH, '//a[contains(@href,"cnx.org/contents/")]' ).click() self.student.page.wait_for_page_load() # check that it says by OpenStax instead of by another author self.student.driver.find_element( By.XPATH, '//span[@ class="collection-authors"]' + '//span[@class="list-comma" and text()="OpenStax College"]' ) self.ps.test_updates['passed'] = True ''' # Case C7627 - 003 - Student | Able to use the table of contents to # navigate the book without impacting the reading assignment @pytest.mark.skipif(str(7627) not in TESTS, reason='Excluded') def test_student_able_to_use_the_table_of_contents_to_navigate_7627(self): """Navigate the book without impacting the reading assignment. Steps: Click on the "Contents" button Expected Result: The user is able to navigate the book without impacting the reading assignment """ self.ps.test_updates['name'] = 'cc1.05.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.05', 'cc1.05.003', '7627'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.login() self.student.driver.find_element( By.XPATH, '//p[contains(text(),"OpenStax Concept Coach")]').click() self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[@class="go-now"]'))).click() self.student.page.wait_for_page_load() self.student.driver.find_element( By.XPATH, '//button[@class="toggle btn"]//span[contains(text(),"Contents")]' ).click() self.student.sleep(0.5) element = self.student.driver.find_element( By.XPATH, '//span[@class="name-wrapper"]' + '//span[@class="chapter-number"]') chapter = element.text element.click() self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[@class="title-chapter" and text()="' + chapter + '"]'))) self.ps.test_updates['passed'] = True # Case C7628 - 004 - Student | Able to search within the book @pytest.mark.skipif(str(7628) not in TESTS, reason='Excluded') def test_student_able_to_search_within_the_book_7628(self): """Able to search within the book. Steps: Enter search words into the search engine next to the "Contents" button Expected Result: The search word is highlighted in yellow within the text and is bolded within the table of contents """ self.ps.test_updates['name'] = 'cc1.05.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.05', 'cc1.05.004', '7628'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.student.login() self.student.driver.find_element( By.XPATH, '//p[contains(text(),"OpenStax Concept Coach")]').click() self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a[@class="go-now"]'))).click() self.student.page.wait_for_page_load() self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//span[text()="Contents"]'))).click() self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//input[@placeholder="Search this book"]' ))).send_keys('balance' + Keys.ENTER) # make sure the search worked # still passes if no results found and it says: No matching results... self.student.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="result-count"]'))) self.ps.test_updates['passed'] = True ''' # Case C7629 - 005 - Teacher | Able to search within the book @pytest.mark.skipif(str(7629) not in TESTS, reason='Excluded') def test_teacher_able_to_search_within_the_book_7629(self): """Able to search within the book. Steps: Go to tutor-qa Click on the 'Login' button Enter the teacher user account in the username and password text boxes Click on the 'Sign in' button If the user has more than one course, click on a CC course name Click "Online Book" in the header Enter search words into the search engine next to the "Contents" button Expected Result: The search word is highlighted in yellow within the text and is bolded within the table of contents """ self.ps.test_updates['name'] = 'cc1.05.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.05', 'cc1.05.005', '7629' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions teacher = Teacher( existing_driver=self.student.driver, username=os.getenv('TEACHER_USER'), password=os.getenv('TEACHER_PASSWORD'), pasta_user=self.ps, capabilities=self.desired_capabilities, ) teacher.login() teacher.driver.find_element( By.XPATH, '//a[contains(@href,"/cc-dashboard/")]' ).click() teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//a//span[contains(text(),"Online Book")]') ) ).click() window_with_book = teacher.driver.window_handles[1] teacher.driver.switch_to_window(window_with_book) assert('cnx' in teacher.current_url()), \ 'Not viewing the textbook PDF' teacher.page.wait_for_page_load() teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//input[@placeholder="Search this book"]') ) ).send_keys('balance' + Keys.ENTER) # make sure the search worked # still passes if no results found and it says: No matching results... teacher.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[@class="result-count"]') ) ) teacher.delete() self.ps.test_updates['passed'] = True ''' # Case C7630 - 006 - Admin | CNX URLs are shorter @pytest.mark.skipif(str(7630) not in TESTS, reason='Excluded') def test_admin_cnx_urls_are_shorter_7630(self): """CNX URLs are shorter. Steps: Go to https://demo.cnx.org/scripts/settings.js Scroll down to the bottom of the page under "conceptCoach" Expected Result: CNX URLs are shorter than the first URL """ self.ps.test_updates['name'] = 'cc1.05.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.05', 'cc1.05.006', '7630'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.get('https://demo.cnx.org/scripts/settings.js') # get the text in the concept coach section page_text = self.admin.wait.until( expect.visibility_of_element_located( (By.TAG_NAME, 'pre'))).text.split('uuids')[1].splitlines() # loop through the lines that are the cnx urls only for i in range(1, len(page_text) - 9, 2): line_1 = page_text[i] line_2 = page_text[i + 1] print(line_1) print(line_2) assert(line_1.find("'", 14) > line_2.find("'", 14)), \ "CNX URLs aren't shorter" 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 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
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 TestOpenStaxMetrics(unittest.TestCase): """CC1.15 - OpenStax Metrics.""" 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 ) 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 C7608 - 001 - Admin | View a report of enrolled students by course @pytest.mark.skipif(str(7608) not in TESTS, reason='Excluded') def test_admin_view_a_report_of_enrolled_students_by_course_7608(self): """View a report of enrolled students by course. 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 'List Students' button for the chosen course Expected Result: List of students for chosen course is displayed """ self.ps.test_updates['name'] = 'cc1.15.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.15', 'cc1.15.001', '7608' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.login() self.admin.open_user_menu() self.admin.find( By.LINK_TEXT, 'Admin' ).click() self.admin.page.wait_for_page_load() self.admin.find( By.LINK_TEXT, 'Course Organization' ).click() self.admin.find( By.LINK_TEXT, 'Courses' ).click() self.admin.page.wait_for_page_load() self.admin.find( By.LINK_TEXT, 'List Students' ).click() # assert thaken to correct page self.admin.find( By.XPATH, '//h1[contains(text(),"Students for course")]' ) assert('student' in self.admin.current_url()) self.ps.test_updates['passed'] = True
class TestAccountMaintenance(unittest.TestCase): """T1.37 - Account 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.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(),"Users")]' ).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 C8247 - 001 - Admin | Search for a username @pytest.mark.skipif(str(8247) not in TESTS, reason='Excluded') def test_admin_search_for_a_username_8247(self): """Search for a username. Steps: Enter a username into the search here text box Click on the 'Search' button Expected Result: A list of users with the search term in their name, or username is displayed. """ self.ps.test_updates['name'] = 't1.37.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.001', '8247'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element( By.ID, 'query').send_keys('Atticus') self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[contains(text(),"Atticus")]') self.ps.test_updates['passed'] = True # Case C8248 - 002 - Admin | Search for a user's name @pytest.mark.skipif(str(8248) not in TESTS, reason='Excluded') def test_admin_search_for_a_users_name_8248(self): """Search for a user's name. 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 'Users' on the bar across the top Enter a user's name into the search here text box Click on the 'Search' button Expected Result: A list of users with the search term in their name, or username is displayed. """ self.ps.test_updates['name'] = 't1.37.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.002', '8248'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element( By.ID, 'query').send_keys('student01') self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[text()="student01"]') self.ps.test_updates['passed'] = True # Case C8249 - 003 - Admin | Create a new user @pytest.mark.skipif(str(8249) not in TESTS, reason='Excluded') def test_admin_create_a_user_8249(self): """Create a new user. Steps: Scroll to the bottom of the page Click on the 'Create user' button Enter account information into: -Username, Password, First name, and Last name text boxes Click on the 'Save' button Expected Result: Takes User back to the Users screen. New user is added. """ self.ps.test_updates['name'] = 't1.37.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.003', '8249'] self.ps.test_updates['passed'] = False # Test steps and verification assertions num = str(randint(0, 999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username')) ).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_'+num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # look up account to check that the account was made self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[text()="automated_test_user_'+num+'"]') self.ps.test_updates['passed'] = True # Case C8250 - 004 - Admin | Edit a user @pytest.mark.skipif(str(8250) not in TESTS, reason='Excluded') def test_admin_edit_a_user_8250(self): """Edit a user. Steps: Create a user to edit Enter the user's name into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user Enter new account information into the First name text box Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's information is updated """ self.ps.test_updates['name'] = 't1.37.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.004', '8250'] self.ps.test_updates['passed'] = False # create a user num = str(randint(1000, 1999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username')) ).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_'+num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]') ) ).click() self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('_EDITED') self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() self.admin.driver.find_element( By.XPATH, '//td[contains(text(),"first_name_' + num + '_EDITED")]') self.ps.test_updates['passed'] = True # Case C8251 - 005 - Admin | Assign elevated permissions @pytest.mark.skipif(str(8251) not in TESTS, reason='Excluded') def test_admin_assign_elevated_permissions_8251(self): """Assign elevated permissions. Steps: Create a user to edit Enter the user's username into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user If check box for chosen permission is not checked, click on check box. Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's permissions are modified. """ self.ps.test_updates['name'] = 't1.37.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.005', '8251'] self.ps.test_updates['passed'] = False # create a user num = str(randint(2000, 2999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username')) ).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_'+num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]') ) ).click() self.admin.driver.find_element( By.ID, 'user_content_analyst').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'Yes'), \ 'permission not elevated ' + element.get_attribute('innerHTML') self.ps.test_updates['passed'] = True # Case C8252 - 006 - Admin | Remove elevated permissions @pytest.mark.skipif(str(8252) not in TESTS, reason='Excluded') def test_admin_remove_elevated_permissions_8252(self): """Remove elevated permissions. Steps: Create a user to edit Enter the user's name into the search here text box Click on the 'Search' button Click on the 'Edit' button next to the user If check box for chosen permission is checked, click to uncheck it. Click on the 'Save' button Expected Result: User is taken back to the User screen. The chosen account's permissions are modified. """ self.ps.test_updates['name'] = 't1.37.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.006', '8252'] self.ps.test_updates['passed'] = False # create a user num = str(randint(3000, 3999)) self.admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") self.admin.driver.find_element( By.XPATH, '//a[contains(text(),"Create user")]').click() self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'user_username')) ).click() self.admin.driver.find_element( By.ID, 'user_username').send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.ID, 'user_password').send_keys('password') self.admin.driver.find_element( By.ID, 'user_first_name').send_keys('first_name_'+num) self.admin.driver.find_element( By.ID, 'user_last_name').send_keys('last_name_'+num) self.admin.driver.find_element( By.ID, 'user_content_analyst').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for that user self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'Yes'), \ 'permission not elevated ' + element.get_attribute('innerHTML') # edit user self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//a[contains(text(),"Edit")]') ) ).click() self.admin.driver.find_element( By.ID, 'user_content_analyst').click() self.admin.driver.find_element( By.XPATH, '//input[@value="Save"]').click() # search for user to make sure they were updated self.admin.wait.until( expect.element_to_be_clickable((By.ID, 'query')) ).send_keys('automated_test_user_'+num) self.admin.driver.find_element( By.XPATH, '//input[@value="Search"]').click() element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]') assert(element.get_attribute('innerHTML') == 'No'), \ 'permission not elevated ' + element.get_attribute('innerHTML') self.ps.test_updates['passed'] = True # Case C8253 - 007 - Admin | Impersonate a user @pytest.mark.skipif(str(8253) not in TESTS, reason='Excluded') def test_admin_impersonate_a_user_8253(self): """Impersonate a user. Steps: Click on the 'Sign in as' button next to a user Expected Result: Signs in as chosen chosen user. Goes to chosen users initial screen after login (different depending on the user) """ self.ps.test_updates['name'] = 't1.37.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.007', '8253'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.admin.driver.find_element(By.ID, 'query').send_keys('student01') 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(),"Atticus Finch")]') ) ) self.ps.test_updates['passed'] = True
def test_admin_distribute_access_codes_for_the_course_7773(self): """Distribute access codes for the teacher's course. Steps: CC approves a faculty. Login as admin Click on user menu Click on Admin Click on Salesforce tab Click on import [Do not check the box] This will automatically create a course for the teacher created. Email is sent to the email id used when signing up with the unique course URL. Expected Result: Instructors are emailed the unique course url to the address provided when they signed up. """ self.ps.test_updates['name'] = 'cc1.01.023' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = [ 'cc1', 'cc1.01', 'cc1.01.023', '7773' ] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) admin = Admin( use_env_vars=True, existing_driver=self.teacher.driver, # pasta_user=self.ps, # capabilities=self.desired_capabilities ) admin.login() admin.open_user_menu() admin.find(By.LINK_TEXT, 'Admin').click() admin.page.wait_for_page_load() admin.find(By.LINK_TEXT, 'Salesforce').click() admin.page.wait_for_page_load() admin.find( By.XPATH, '//input[@vale="Import Courses"]' ).click() self.ps.test_updates['passed'] = True
class TestManageEcosystems(unittest.TestCase): 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) self.content = ContentQA(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: self.admin = Admin(use_env_vars=True) self.content = ContentQA(use_env_vars=True, existing_driver=self.admin.driver) self.wait = WebDriverWait(self.admin.driver, Assignment.WAIT_TIME) self.admin.login() self.wait.sleep(2) 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() # self.content.delete() except: pass def test_content_tag_search_admin(self): """ Go to https://tutor-qa.openstax.org/ Login to admin account Open the drop down menu by clicking on the user menu link containing the user's name Click on the 'Admin' button Open the drop down menu by clicking 'Content' Click the 'Tags' button Enter text into the text box with 'Search here' Click the 'Search' button ***Results of the search are returned.(t1.58.19)*** Click the 'Edit' button for one of the returned tags Edit the text box labeled 'Name' Edit the text box labeled 'Description' Click the 'Save' button ***The user is returned to the Tags page and the text 'The tag has been updated.' is displayed. (t1.58.20)*** :return: CORRESPONDS TO: t1.58.19,20 """ # t1.58.19 --> Results of the search are returned. content_dropdown = "//a[contains(@class,'dropdown-toggle') and " + \ "contains(text(),'Content')]" content_ecosystems = "//a[contains(text(),'Tags')]" search_term = "bio" search_btn = "//input[contains(@value,'Search')]" # (t1.58.20) --> The user is returned to the Tags page and the text # 'The tag has been updated.' is displayed. edit = "//a[contains(@edit,'Edit')]" # NEED CODE FOR ACTUALLY FILLING IN TEXTBOXES print(content_dropdown, content_ecosystems, search_term, search_btn) print(edit) self.admin.find(By.XPATH, "//div[contains(@class,'alert-info')]") self.admin.find( By.XPATH, "//div[contains(@class,'alert-info')]" + "//*[contains(text(),'The tag has been updated')]")
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 '''
def setUp(self): """Pretest settings.""" self.admin = Admin(use_env_vars=True, driver_type=DRIVER) self.admin.set_window_size(height=700, width=1200)
class TestUserLogin(unittest.TestCase): """T1.36 - User login.""" 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) self.content = ContentQA(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.student = Student(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) self.teacher = Teacher(existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities) else: self.admin = Admin(use_env_vars=True, ) self.content = ContentQA( existing_driver=self.admin.driver, use_env_vars=True, ) self.student = Student( existing_driver=self.admin.driver, use_env_vars=True, ) self.teacher = Teacher( existing_driver=self.admin.driver, use_env_vars=True, ) 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.teacher = None self.student = None self.content = None self.admin.delete() except: pass # Case C8238 - 001 - Admin | Log into Tutor @pytest.mark.skipif(str(8238) not in TESTS, reason='Excluded') def test_admin_log_into_tutor_8238(self): """Log into Tutor. Steps: Click on the 'Log in' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Expected Result: User is logged in """ self.ps.test_updates['name'] = 't1.36.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.001', '8238'] self.ps.test_updates['passed'] = False self.admin.get(self.admin.url) self.admin.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.admin.driver.get_window_size()['width'] <= \ self.admin.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.admin.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]') # check if the menu is collapsed and, if yes, open it if ('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Log in'))).click() self.admin.page.wait_for_page_load() self.admin.find(By.ID, 'login_username_or_email') \ .send_keys(self.admin.username) self.admin.find(By.XPATH, "//input[@value='Next']").click() self.admin.find(By.ID, 'login_password') \ .send_keys(self.admin.password) # click on the sign in button self.admin.find(By.XPATH, "//input[@value='Log in']").click() self.admin.page.wait_for_page_load() assert('dashboard' in self.admin.current_url()), \ 'Not taken to dashboard: %s' % self.admin.current_url() self.ps.test_updates['passed'] = True # Case C8239 - 002 - Admin | Access the Admin Console @pytest.mark.skipif(str(8239) not in TESTS, reason='Excluded') def test_admin_access_the_admin_console_8239(self): """Access the Admin console. Steps: Click on the 'Log in' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click on the user menu Click on the Admin option Expected Result: User is presented with the admin console """ self.ps.test_updates['name'] = 't1.36.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.002', '8239'] self.ps.test_updates['passed'] = False self.admin.login() 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.find(By.XPATH, '//h1[contains(text(),"Admin Console")]') self.ps.test_updates['passed'] = True # Case C8240 - 003 - Admin | Log out @pytest.mark.skipif(str(8240) not in TESTS, reason='Excluded') def test_admin_log_out_8240(self): """Log out. Steps: Click on the 'Log in' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The User is signed out """ self.ps.test_updates['name'] = 't1.36.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.003', '8240'] self.ps.test_updates['passed'] = False self.admin.login() self.admin.open_user_menu() self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log out")]'))).click() self.admin.page.wait_for_page_load() self.admin.find(By.XPATH, '//div[contains(@class,"tutor-home")]') self.ps.test_updates['passed'] = True # Case C8241 - 004 - Content Analyst | Log into Tutor @pytest.mark.skipif(str(8241) not in TESTS, reason='Excluded') def test_content_analyst_log_into_tutor_8241(self): """Log into Tutor. Steps: Click on the 'Log in' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Expected Result: The user is signed in """ self.ps.test_updates['name'] = 't1.36.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.004', '8241'] self.ps.test_updates['passed'] = False self.content.get(self.content.url) self.content.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.content.driver.get_window_size()['width'] <= \ self.content.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.content.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]') # check if the menu is collapsed and, if yes, open it if ('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.content.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Log in'))).click() self.content.page.wait_for_page_load() self.content.find(By.ID, 'login_username_or_email') \ .send_keys(self.content.username) self.content.find(By.XPATH, "//input[@value='Next']").click() self.content.find(By.ID, 'login_password') \ .send_keys(self.content.password) # click on the sign in button self.content.find(By.XPATH, "//input[@value='Log in']").click() self.content.page.wait_for_page_load() assert('dashboard' in self.content.current_url()), \ 'Not taken to dashboard: %s' % self.content.current_url() self.ps.test_updates['passed'] = True # Case C8242 - 005 - Content Analyst | Access the QA Viewer @pytest.mark.skipif(str(8242) not in TESTS, reason='Excluded') def test_content_analyst_access_the_qa_viewer_8242(self): """Access the QA Viewer. Steps: Click on the 'Log in' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the QA Content option Expected Result: The user is presented with the QA viewer """ self.ps.test_updates['name'] = 't1.36.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.005', '8242'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable( (By.XPATH, '//div[contains(text(),"QA Content")]'))).click() self.content.page.wait_for_page_load() assert('/qa' in self.content.current_url()), \ 'Not taken to the QA viewer: %s' % self.content.current_url() self.ps.test_updates['passed'] = True # Case C8243 - 006 - Content Analyst | Access the Content Analyst Console @pytest.mark.skipif(str(8243) not in TESTS, reason='Excluded') def test_content_analyst_access_the_content_analyst_console_8243(self): """Access the Content Annalyst Console. Steps: Click on the 'Log in' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Content Analyst option Expected Result: The user is presented with the Content Analyst Console """ self.ps.test_updates['name'] = 't1.36.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.006', '8243'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable( (By.XPATH, '//div[contains(text(),"Content Analyst")]'))).click() self.content.page.wait_for_page_load() self.content.find(By.XPATH, '//h1[contains(text(),"Content Analyst Console")]') self.ps.test_updates['passed'] = True # Case C8244 - 007 - Content Analyst | Log out @pytest.mark.skipif(str(8244) not in TESTS, reason='Excluded') def test_content_analyst_log_out_8244(self): """Log out. Steps: Click on the 'Log in' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.007', '8244'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log out")]'))).click() self.content.page.wait_for_page_load() self.content.find(By.XPATH, '//div[contains(@class,"tutor-home")]') self.ps.test_updates['passed'] = True # Case C8245 - 008 - Student | Log into Tutor @pytest.mark.skipif(str(8245) not in TESTS, reason='Excluded') def test_student_log_into_tutor_8245(self): """Log into Tutor. Steps: Click on the 'Log in' button Enter the student account in the username and password text boxes Click on the 'Sign in' button Expected Result: The user is logged in """ self.ps.test_updates['name'] = 't1.36.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.008', '8245'] self.ps.test_updates['passed'] = False self.student.get(self.student.url) self.student.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.student.driver.get_window_size()['width'] <= \ self.student.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.student.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]') # check if the menu is collapsed and, if yes, open it if ('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.student.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Log in'))).click() self.student.page.wait_for_page_load() self.student.find(By.ID, 'login_username_or_email') \ .send_keys(self.student.username) self.student.find(By.XPATH, "//input[@value='Next']") \ .click() self.student.find(By.ID, 'login_password') \ .send_keys(self.student.password) # click on the sign in button self.student.find(By.XPATH, "//input[@value='Log in']").click() self.student.page.wait_for_page_load() assert('dashboard' in self.student.current_url()), \ 'Not taken to dashboard: %s' % self.student.current_url() self.ps.test_updates['passed'] = True # Case C8246 - 009 - Teacher | Log into Tutor @pytest.mark.skipif(str(8246) not in TESTS, reason='Excluded') def test_teacher_log_into_tutor_8246(self): """Log into Tutor. Steps: Click on the 'Log in' button Enter the teacher account in the username and password text boxes Click on the 'Sign in' button Expected Result: The user is logged in """ self.ps.test_updates['name'] = 't1.36.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.009', '8246'] self.ps.test_updates['passed'] = False self.teacher.get(self.teacher.url) self.teacher.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.teacher.driver.get_window_size()['width'] <= \ self.teacher.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.teacher.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]') # check if the menu is collapsed and, if yes, open it if ('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.teacher.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Log in'))).click() self.teacher.page.wait_for_page_load() self.teacher.find(By.ID, 'login_username_or_email') \ .send_keys(self.teacher.username) self.teacher.find(By.XPATH, "//input[@value='Next']").click() self.teacher.find(By.ID, 'login_password') \ .send_keys(self.teacher.password) # click on the sign in button self.teacher.find(By.XPATH, "//input[@value='Log in']").click() self.teacher.page.wait_for_page_load() assert('dashboard' in self.teacher.current_url()),\ 'Not taken to dashboard: %s' % self.teacher.current_url() self.ps.test_updates['passed'] = True # Case C58271 - 010 - Student | Log out @pytest.mark.skipif(str(58271) not in TESTS, reason='Excluded') def test_content_analyst_log_out_58271(self): """Log out. Steps: Click on the 'Log in' button Enter the student account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.010', '58271'] self.ps.test_updates['passed'] = False self.student.login() self.student.open_user_menu() self.student.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log out")]'))).click() self.student.page.wait_for_page_load() self.student.find(By.XPATH, '//div[contains(@class,"tutor-home")]') self.ps.test_updates['passed'] = True # Case C58272 - 011 - Teacher | Log out @pytest.mark.skipif(str(58272) not in TESTS, reason='Excluded') def test_teacher_log_out_58272(self): """Log out. Steps: Click on the 'Log in' button Enter the teacher account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.011', '58272'] self.ps.test_updates['passed'] = False self.teacher.login() self.teacher.open_user_menu() self.teacher.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log out")]'))).click() self.teacher.page.wait_for_page_load() self.teacher.find(By.XPATH, '//div[contains(@class,"tutor-home")]') self.ps.test_updates['passed'] = True # Case C96962 - 012 - Content Reviewer | Log into Exercises @pytest.mark.skipif(str(96962) not in TESTS, reason='Excluded') def test_content_reviewer_log_into_exercises_96962(self): """Log into Exercises. Steps: Go to https://exercises-qa.openstax.org/ Click "SIGN IN" Enter the Content username into "Email or username" text box Click "Next" Enter the Content password into "password" text box Click "Login" Expected Result: User is logged in """ self.ps.test_updates['name'] = 't1.36.012' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.012', '96962'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.content.driver.get("https://exercises-qa.openstax.org/") self.content.sleep(3) self.content.find(By.LINK_TEXT, "SIGN IN").click() self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \ .send_keys(os.getenv('CONTENT_USER')) self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \ .send_keys(Keys.RETURN) self.content.sleep(2) self.content.find(By.XPATH, "//input[@id='login_password']") \ .send_keys(os.getenv('CONTENT_PASSWORD')) self.content.find(By.XPATH, "//input[@id='login_password']") \ .send_keys(Keys.RETURN) self.content.sleep(3) self.content.find(By.LINK_TEXT, "SIGN OUT") self.ps.test_updates['passed'] = True # Case C96963 - 013 - Content Reviewer | Access Reviewer Display @pytest.mark.skipif(str(96963) not in TESTS, reason='Excluded') def test_content_reviewer_access_reviewer_display_96963(self): """Access Reviewer Display. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.36.013' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.013', '96963'] 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 C96964 - 014 - Content Reviewer | Log out @pytest.mark.skipif(str(96964) not in TESTS, reason='Excluded') def test_content_reviewer_log_out_96964(self): """Log out. Steps: go to https://exercises-qa.openstax.org/ Click "SIGN IN" Enter [content] into "Email or username" text box Click "Next" Enter [staxly16] into "password" text box Click "Login" Click "SIGN OUT" Expected Result: User is logged out. """ self.ps.test_updates['name'] = 't1.36.014' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.014', '96964'] self.ps.test_updates['passed'] = False # Test steps and verification assertions self.content.driver.get("https://exercises-qa.openstax.org/") self.content.sleep(3) self.content.find(By.LINK_TEXT, "SIGN IN").click() self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \ .send_keys(os.getenv('CONTENT_USER')) self.content.find(By.XPATH, "//input[@id='login_username_or_email']") \ .send_keys(Keys.RETURN) self.content.sleep(2) self.content.find(By.XPATH, "//input[@id='login_password']") \ .send_keys(os.getenv('CONTENT_PASSWORD')) self.content.find(By.XPATH, "//input[@id='login_password']") \ .send_keys(Keys.RETURN) self.content.sleep(3) self.content.find(By.LINK_TEXT, "SIGN OUT").click() self.content.sleep(2) self.content.find(By.LINK_TEXT, "SIGN IN") self.ps.test_updates['passed'] = True # Case C96965 - 015 - Content Editor | Log into Exercises @pytest.mark.skipif(str(96965) not in TESTS, reason='Excluded') def test_content_editor_log_into_exercises_96965(self): """Log into Exercises. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.36.015' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.015', '96965'] 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 C96962 - 016 - Content Editor | Access the Exercise Editor @pytest.mark.skipif(str(96966) not in TESTS, reason='Excluded') def test_content_editor_access_the_exercise_editor_96966(self): """Access the Exercise Editor. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.36.016' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.016', '96966'] 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 C96967 - 017 - Content Editor | Log out @pytest.mark.skipif(str(96967) not in TESTS, reason='Excluded') def test_content_editor_log_out_96967(self): """Log out. Steps: Expected Result: """ self.ps.test_updates['name'] = 't1.36.017' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.017', '96967'] 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 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 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 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 TestManageDistricsSchoolsAndCourses(unittest.TestCase): 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.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_district_admin(self): """ Go to https://tutor-qa.openstax.org/ Click on the 'Login' button Login to admin account Click on the 'Sign in' button Click on the user menu in the right corner of the header Click "Admin" Click "Course Organization" in the header Click "Districts" Click "Add district" Enter a name for the district in the Name text box Click "Save" ***A new district is added and the user is returned to the 'Districts' section (t1.59.01)*** Click "edit" for a district Enter a new name into the Name text box Click "Save" ***A district's name is changed (t1.59.02) and user should be returned to 'Districts' section*** Click "delete" for the desired district Click "OK" on the dialogue box ***An existing district is deleted (t1.59.03)*** Corresponds to... T1.59 01 --> 3 :return: """ def test_school_admin(self): """ Go to https://tutor-qa.openstax.org/ Login to admin account Click on the 'Sign in' button Click on the user menu in the right corner of the header Click "Admin" Click "Course Organization" in the header Click "Schools" Click "Add school" Enter a name for the school in the Name text box Click "Save" ***A new school is added and the user is returned to the 'Schools' section (t1.59.04)*** Click "edit" for a school Enter a new name into the Name text box Click "Save" ***A school's name is changed (t1.59.05) and user should be returned to 'School' section*** Click "edit" for the desired school Select a new district Click "Save" ***A school's district is changed (t1.59.06)*** Click "delete" for the desired school Click "OK" on the dialogue box ***An existing school is deleted (t1.59.07)*** Corresponds to... T1.59 04 --> 07 :return: """ def test_course_admin(self): """ Pre-req: 'Course-Navigate' Click "Add course" Enter a name in the Name text box Click "Save" ***A new course is added and the user is returned to the 'Courses' section (t1.59.08)*** Click "Edit" for a school Change information in desired text boxes Click "Save" ***The course is edited (t1.59.09) and user should be returned to list of all courses*** Corresponds to... T1.59 08--> 9 :return: """ def test_periods_admin(self): """ Pre-Req "Course-Navigate" Click "Edit" on the desired course Click the "Periods" tab Click "Add Period" Enter a name into the Name text box Click "Save" ***A new empty period is added (t1.59.14)*** Click "Edit" on the desired course Click the "Periods" tab Click "Edit" for the desired period enter new information into the name and enrollment code text boxes Click on the "Save" button ***Period is edited (t1.59.15)*** Click "Edit" on the desired course Click the "Periods" tab Click "Delete" for an empty period ***Empty period is deleted (t1.59.16)*** Click "Edit" on the desired course Click the "Periods" tab Click "Delete" on a non-empty period ***A non-empty period is deleted (t1.59.17)*** Corresponds to... t1.59 14 --> 17 :return: """ def test_teachers_admin(self): """ Click "Edit" on the desired course Click the "Teachers" tab Enter the teacher's name or the username into the search engine Click on the name that matches the teacher's name or the username ***A teacher is added to a course (t1.59.10) and user directed back to the 'Courses' section*** Click "Edit" on the desired course Click the "Teachers" tab Click "Remove from course" for the desired teacher Click "OK" on the dialogue box ***A teacher is removed from a course (t1.59.11)*** Corresponds to... t1.59. 10,11 :return: """ def test_course_ecosystem_admin(self): """ Pre-req: 'Course Navigate' Click "edit" on the desired course Click the "course content" tab Select a course ecosystem Click "Submit" ***Request for course ecosystem update submitted and message displayed (t1.59.12)*** Click "edit" on the desired course Click the "course content" tab Select a course ecosystem Click "Submit" ***The course ecosystem is queued for the course (t1.59.13)*** Check the desired courses to update Scroll to the bottom of the page Select an ecosystem Click "Set ecosystem" ***The message "Course ecosystem update background jobs queued" appears beneath the page title "Courses" (t1.59.19)*** CORRESPONDS TO... T1.59 12,13,19 :return: """ def test_tutor_student_count_admin(self): """
def test_admin_import_content_into_tutor_7604(self): """Import content into Tutor. Steps: Select Customer Analyst from the dropdown menu on the name Click on Ecosystems in the header Click "Download Manifest" for the desired course Scroll down and click Import a new Ecosystem button. Click "Choose File" Select the downloaded file In comment section add today's date and your name. Eg: 2016-03-03 Kajal Click on the button Import Now wait for at most 5 mins. Expected Result: The message "Ecosystem import job queued" appears at the top """ self.ps.test_updates['name'] = 'cc1.03.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.03', 'cc1.03.002', '7604'] self.ps.test_updates['passed'] = False # Test steps and verification assertions if not LOCAL_RUN: admin = Admin( use_env_vars=True, existing_driver=self.content.driver, pasta_user=self.ps, capabilities=self.desired_capabilities, ) else: admin = Admin( use_env_vars=True, existing_driver=self.content.driver, ) admin.login() admin.open_user_menu() admin.driver.find_element(By.LINK_TEXT, "Content Analyst").click() admin.page.wait_for_page_load() admin.driver.find_element(By.LINK_TEXT, "Ecosystems").click() # download a manifest to test with admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, "Download Manifest"))).click() # import a new ecosystem admin.driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") admin.driver.find_element(By.LINK_TEXT, "Import a new Ecosystem").click() # find a downloaded manifest home = os.getenv("HOME") files = os.listdir(home + '/Downloads') file = '' for i in range(len(files)): if (files[i][-4:] == '.yml'): file = files[i] break else: if i == len(files) - 1: print('no .yml file found in downloads') raise Exception admin.wait.until( expect.visibility_of_element_located( (By.ID, "ecosystem_manifest"))).send_keys(home + '/Downloads/' + file) admin.wait.until( expect.visibility_of_element_located( (By.ID, "ecosystem_comments"))).send_keys( str(datetime.date.today()) + ' automated-admin') admin.driver.find_element(By.XPATH, "//input[@type='submit']").click() admin.wait.until( expect.visibility_of_element_located( (By.XPATH, '//div[contains(@class,"alert-info")]'))) admin.delete() self.ps.test_updates['passed'] = True
def test_admin_distribute_access_codes_for_the_course_7773(self): """Distribute access codes for the teacher's course. Steps: CC approves a faculty. Login as admin Click on user menu Click on Admin Click on Salesforce tab Click on import [Do not check the box] This will automatically create a course for the teacher created. Email is sent to the email id used when signing up with the unique course URL. Expected Result: Instructors are emailed the unique course url to the address provided when they signed up. """ self.ps.test_updates['name'] = 'cc1.01.023' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.023', '7773'] self.ps.test_updates['passed'] = False # Test steps and verification assertions raise NotImplementedError(inspect.currentframe().f_code.co_name) admin = Admin( use_env_vars=True, existing_driver=self.teacher.driver, # pasta_user=self.ps, # capabilities=self.desired_capabilities ) admin.login() admin.open_user_menu() admin.find(By.LINK_TEXT, 'Admin').click() admin.page.wait_for_page_load() admin.find(By.LINK_TEXT, 'Salesforce').click() admin.page.wait_for_page_load() admin.find(By.XPATH, '//input[@vale="Import Courses"]').click() self.ps.test_updates['passed'] = True
def setUp(self): """Pretest settings.""" self.admin = Admin(use_env_vars=True) self.admin.set_window_size(height=700, width=1200)
class TestUserLogin(unittest.TestCase): """T1.36 - User login.""" 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.content = ContentQA( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.student = Student( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) self.teacher = Teacher( existing_driver=self.admin.driver, use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities ) def tearDown(self): """Test destructor.""" self.ps.update_job( job_id=str(self.admin.driver.session_id), **self.ps.test_updates ) try: self.teacher = None self.student = None self.content = None self.admin.delete() except: pass # Case C8238 - 001 - Admin | Log into Tutor @pytest.mark.skipif(str(8238) not in TESTS, reason='Excluded') def test_admin_log_into_tutor_8238(self): """Log into Tutor. Steps: Click on the 'Login' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Expected Result: User is logged in """ self.ps.test_updates['name'] = 't1.36.001' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.001', '8238'] self.ps.test_updates['passed'] = False self.admin.get(self.admin.url) self.admin.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.admin.driver.get_window_size()['width'] <= \ self.admin.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.admin.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]' ) # check if the menu is collapsed and, if yes, open it if('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.admin.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Login') ) ).click() self.admin.page.wait_for_page_load() self.admin.find( By.ID, 'auth_key' ).send_keys(self.admin.username) self.admin.find( By.ID, 'password' ).send_keys(self.admin.password) # click on the sign in button self.admin.find( By.XPATH, '//button[text()="Sign in"]' ).click() self.admin.page.wait_for_page_load() assert('dashboard' in self.admin.current_url()), \ 'Not taken to dashboard: %s' % self.admin.current_url() self.ps.test_updates['passed'] = True # Case C8239 - 002 - Admin | Access the Admin Console @pytest.mark.skipif(str(8239) not in TESTS, reason='Excluded') def test_admin_access_the_admin_console_8239(self): """Access the Admin console. Steps: Click on the 'Login' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click on the user menu Click on the Admin option Expected Result: User is presented with the admin console """ self.ps.test_updates['name'] = 't1.36.002' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.002', '8239'] self.ps.test_updates['passed'] = False # self.user = admin self.admin.login() 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.find( By.XPATH, '//h1[contains(text(),"Admin Console")]') self.ps.test_updates['passed'] = True # Case C8240 - 003 - Admin | Log out @pytest.mark.skipif(str(8240) not in TESTS, reason='Excluded') def test_admin_log_out_8240(self): """Log out. Steps: Click on the 'Login' button Enter the admin account in the username and password text boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The User is signed out """ self.ps.test_updates['name'] = 't1.36.003' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.003', '8240'] self.ps.test_updates['passed'] = False self.admin.login() self.admin.open_user_menu() self.admin.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log Out")]') ) ).click() self.admin.page.wait_for_page_load() self.admin.find( By.XPATH, '//div[contains(@class,"tutor-home")]') self.ps.test_updates['passed'] = True # Case C8241 - 004 - Content Analyst | Log into Tutor @pytest.mark.skipif(str(8241) not in TESTS, reason='Excluded') def test_content_analyst_log_into_tutor_8241(self): """Log into Tutor. Steps: Click on the 'Login' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Expected Result: The user is signed in """ self.ps.test_updates['name'] = 't1.36.004' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.004', '8241'] self.ps.test_updates['passed'] = False self.content.get(self.content.url) self.content.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.content.driver.get_window_size()['width'] <= \ self.content.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.content.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]' ) # check if the menu is collapsed and, if yes, open it if('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.content.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Login') ) ).click() self.content.page.wait_for_page_load() self.content.find( By.ID, 'auth_key' ).send_keys(self.content.username) self.content.find( By.ID, 'password' ).send_keys(self.content.password) # click on the sign in button self.content.find( By.XPATH, '//button[text()="Sign in"]' ).click() self.content.page.wait_for_page_load() assert('dashboard' in self.content.current_url()), \ 'Not taken to dashboard: %s' % self.content.current_url() self.ps.test_updates['passed'] = True # Case C8242 - 005 - Content Analyst | Access the QA Viewer @pytest.mark.skipif(str(8242) not in TESTS, reason='Excluded') def test_content_analyst_access_the_qa_viewer_8242(self): """Access the QA Viewer. Steps: Click on the 'Login' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the QA Content option Expected Result: The user is presented with the QA viewer """ self.ps.test_updates['name'] = 't1.36.005' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.005', '8242'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable(( By.XPATH, '//a[contains(text(),"QA Content") and @role="menuitem"]' )) ).click() self.content.page.wait_for_page_load() assert('/qa' in self.content.current_url()), \ 'Not taken to the QA viewer: %s' % self.content.current_url() self.ps.test_updates['passed'] = True # Case C8243 - 006 - Content Analyst | Access the Content Analyst Console @pytest.mark.skipif(str(8243) not in TESTS, reason='Excluded') def test_content_analyst_access_the_content_analyst_console_8243(self): """Access the Content Annalyst Console. Steps: Click on the 'Login' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Content Analyst option Expected Result: The user is presented with the Content Analyst Console """ self.ps.test_updates['name'] = 't1.36.006' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.006', '8243'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable(( By.XPATH, '//a[contains(text(),"Content Analyst") and @role="menuitem"]' )) ).click() self.content.page.wait_for_page_load() self.content.find( By.XPATH, '//h1[contains(text(),"Content Analyst Console")]' ) self.ps.test_updates['passed'] = True # Case C8244 - 007 - Content Analyst | Log out @pytest.mark.skipif(str(8244) not in TESTS, reason='Excluded') def test_content_analyst_log_out_8244(self): """Log out. Steps: Click on the 'Login' button Enter the content analyst account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.007' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.007', '8244'] self.ps.test_updates['passed'] = False self.content.login() self.content.open_user_menu() self.content.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log Out")]') ) ).click() self.content.page.wait_for_page_load() self.content.find( By.XPATH, '//div[contains(@class,"tutor-home")]' ) self.ps.test_updates['passed'] = True # Case C8245 - 008 - Student | Log into Tutor @pytest.mark.skipif(str(8245) not in TESTS, reason='Excluded') def test_student_log_into_tutor_8245(self): """Log into Tutor. Steps: Click on the 'Login' button Enter the student account in the username and password text boxes Click on the 'Sign in' button Expected Result: The user is logged in """ self.ps.test_updates['name'] = 't1.36.008' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.008', '8245'] self.ps.test_updates['passed'] = False self.student.get(self.student.url) self.student.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.student.driver.get_window_size()['width'] <= \ self.student.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.student.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]' ) # check if the menu is collapsed and, if yes, open it if('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.student.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Login') ) ).click() self.student.page.wait_for_page_load() self.student.find( By.ID, 'auth_key' ).send_keys(self.student.username) self.student.find( By.ID, 'password' ).send_keys(self.student.password) # click on the sign in button self.student.find( By.XPATH, '//button[text()="Sign in"]' ).click() self.student.page.wait_for_page_load() assert('dashboard' in self.student.current_url()), \ 'Not taken to dashboard: %s' % self.student.current_url() self.ps.test_updates['passed'] = True # Case C8246 - 009 - Teacher | Log into Tutor @pytest.mark.skipif(str(8246) not in TESTS, reason='Excluded') def test_teacher_log_into_tutor_8246(self): """Log into Tutor. Steps: Click on the 'Login' button Enter the teacher account in the username and password text boxes Click on the 'Sign in' button Expected Result: The user is logged in """ self.ps.test_updates['name'] = 't1.36.009' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.009', '8246'] self.ps.test_updates['passed'] = False self.teacher.get(self.teacher.url) self.teacher.page.wait_for_page_load() # check to see if the screen width is normal or condensed if self.teacher.driver.get_window_size()['width'] <= \ self.teacher.CONDENSED_WIDTH: # get small-window menu toggle is_collapsed = self.teacher.find( By.XPATH, '//button[contains(@class,"navbar-toggle")]' ) # check if the menu is collapsed and, if yes, open it if('collapsed' in is_collapsed.get_attribute('class')): is_collapsed.click() self.teacher.wait.until( expect.visibility_of_element_located( (By.LINK_TEXT, 'Login') ) ).click() self.teacher.page.wait_for_page_load() self.teacher.find( By.ID, 'auth_key' ).send_keys(self.teacher.username) self.teacher.find( By.ID, 'password' ).send_keys(self.teacher.password) # click on the sign in button self.teacher.find( By.XPATH, '//button[text()="Sign in"]' ).click() self.teacher.page.wait_for_page_load() assert('dashboard' in self.teacher.current_url()),\ 'Not taken to dashboard: %s' % self.teacher.current_url() self.ps.test_updates['passed'] = True # Case C58271 - 010 - Student | Log out @pytest.mark.skipif(str(58271) not in TESTS, reason='Excluded') def test_content_analyst_log_out_58271(self): """Log out. Steps: Click on the 'Login' button Enter the student account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.010' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.010', '58271'] self.ps.test_updates['passed'] = False self.student.login() self.student.open_user_menu() self.student.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log Out")]') ) ).click() self.student.page.wait_for_page_load() self.student.find( By.XPATH, '//div[contains(@class,"tutor-home")]' ) self.ps.test_updates['passed'] = True # Case C58272 - 011 - Teacher | Log out @pytest.mark.skipif(str(58272) not in TESTS, reason='Excluded') def test_teacher_log_out_58272(self): """Log out. Steps: Click on the 'Login' button Enter the teacher account in the username and password boxes Click on the 'Sign in' button Click on the user menu Click on the Log out option Expected Result: The user is logged out """ self.ps.test_updates['name'] = 't1.36.011' \ + inspect.currentframe().f_code.co_name[4:] self.ps.test_updates['tags'] = ['t1', 't1.36', 't1.36.011', '58272'] self.ps.test_updates['passed'] = False self.teacher.login() self.teacher.open_user_menu() self.teacher.wait.until( expect.element_to_be_clickable( (By.XPATH, '//input[contains(@value,"Log Out")]') ) ).click() self.teacher.page.wait_for_page_load() self.teacher.find( By.XPATH, '//div[contains(@class,"tutor-home")]' ) 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 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