class TestEditCourseSettingsAndRoster(unittest.TestCase):
    """T1.42 - Edit Course Settings and Roster."""

    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.teacher.login()
        self.teacher.select_course(appearance='physics')
        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()

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.teacher.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.teacher.delete()
        except:
            pass

    # Case C8258 - 001 - Teacher | Edit the course name
    @pytest.mark.skipif(str(8258) not in TESTS, reason='Excluded')
    def test_teacher_edit_the_course_name_8258(self):
        """Edit the course name.

        Steps:
        Click the "Rename Course" button that is next to the course name
        Enter a new course name
        Click the "Rename" button
        Click the X that is on the upper right corner of the dialogue box

        Expected Result:
        The course name is edited.
        (then put it back at the end)
        """
        self.ps.test_updates['name'] = 't1.42.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.001', '8258']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        course_name = self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="course-settings-title"]/span'
        ).text
        self.teacher.find(
            By.XPATH, '//button[contains(@class,"edit-course")]' +
            '//span[contains(text(),"Rename Course")]'
        ).click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys('_EDIT')
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-course-confirm")]'
        ).click()
        # check that it was edited
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[@class="course-settings-title"]' +
                 '/span[contains(text(),"%s_EDIT")]' % course_name)
            )
        )
        # set it back
        self.teacher.sleep(1)
        self.teacher.driver.find_element(
            By.XPATH,
            '//button[contains(@class,"edit-course")]' +
            '//span[contains(text(),"Rename Course")]'
        ).click()
        for _ in range(len('_EDIT')):
            self.teacher.wait.until(
                expect.element_to_be_clickable(
                    (By.XPATH, '//input[contains(@class,"form-control")]')
                )
            ).send_keys(Keys.BACK_SPACE)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-course-confirm")]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[@class="course-settings-title"]' +
                 '/span[text()="%s"]' % course_name)
            )
        )

        self.ps.test_updates['passed'] = True

    # Case C8259 - 002 - Teacher | Remove an instructor from the course
    @pytest.mark.skipif(str(8259) not in TESTS, reason='Excluded')
    def test_teacher_remove_an_instructor_from_a_course_8259(self):
        """Remove an instructor from the course.

        Steps:
        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.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.002', '8259']
        self.ps.test_updates['passed'] = False

        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

    # Case C8260 - 003 - Teacher | Remove the last instructor from the course
    @pytest.mark.skipif(str(8260) not in TESTS, reason='Excluded')
    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

    # Case C8261 - 004 - Teacher | Add a period
    @pytest.mark.skipif(str(8261) not in TESTS, reason='Excluded')
    def test_teacher_add_a_period_8261(self):
        """Add a period.

        Steps:
        Click "+ Add Period"
        Enter a period name into the Period Name text box
        Click "Add"

        Expected Result:
        A new period is added.
        """
        self.ps.test_updates['name'] = 't1.42.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.004', '8261']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')

        self.ps.test_updates['passed'] = True

    # Case C8262 - 005 - Teacher | Rename a period
    @pytest.mark.skipif(str(8262) not in TESTS, reason='Excluded')
    def test_teacher_rename_a_period_8262(self):
        """Rename a period.

        Steps:
        Click "Rename Period"
        Enter a new period name into the Period Name text box
        Click "Rename"

        Expected Result:
        A period is renamed.
        """
        self.ps.test_updates['name'] = 't1.42.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.005', '8262']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # edit the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//span[contains(@class,"rename-period")]/button'
        ).click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys('_EDIT')
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'_EDIT")]')

        self.ps.test_updates['passed'] = True

    # Case C8263 - 006 - Teacher | Archive an empty period
    @pytest.mark.skipif(str(8263) not in TESTS, reason='Excluded')
    def test_teacher_archive_an_empt_period_8263(self):
        """Archive an empty period.

        Steps:
        Click on an empty period
        Click "Archive Period"
        Click "Archive" on the dialogue box

        Expected Result:
        An empty period is archived.
        """
        self.ps.test_updates['name'] = 't1.42.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.006', '8263']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # edit the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.sleep(2)
        archived_period = self.teacher.find_all(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')
        assert(len(archived_period) == 0), 'period not archived'

        self.ps.test_updates['passed'] = True

    # Case C8264 - 007 - Teacher | Archive a non-empty period
    @pytest.mark.skipif(str(8264) not in TESTS, reason='Excluded')
    def test_teacher_archive_a_non_empty_period_8264(self):
        """Archive a non-empty period.

        Steps:
        Click on a non-empty period
        Click "Archive Period"
        Click Archive

        Expected Result:
        Period is archived
        """
        self.ps.test_updates['name'] = 't1.42.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.007', '8264']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        period_name = self.teacher.find(
            By.XPATH, '//ul[@role="tablist"]//a[@role="tab"]').text
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.find(
            By.XPATH, '//span[contains(text(),"View Archived")]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="modal-body"]//td[contains(text(),"' +
            period_name + '")]')
        # add the section back
        periods = self.teacher.find_all(
            By.XPATH, '//div[@class="modal-body"]//table//tbody//tr')
        for x in range(len(periods)):
            temp_period = self.teacher.find(
                By.XPATH, '//div[@class="modal-body"]//table//tbody' +
                '//tr['+str(x+1)+']/td').text
            if temp_period == period_name:
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="modal-body"]//table//tbody//tr[' +
                    str(x+1) + ']//button//span[contains(text(),"Unarchive")]'
                ).click()
                break

        self.ps.test_updates['passed'] = True

    # Case C8265 - 008 - Teacher | Move a student to another period
    @pytest.mark.skipif(str(8265) not in TESTS, reason='Excluded')
    def test_teacher_mover_a_student_to_another_period_8265(self):
        """Move a student to another period.

        Steps:
        Click on the user menu in the upper right corner of the page
        Click "Course Roster"
        Click "Change Period" for a student under the Roster section
        Click the desired period to move a student

        Expected Result:
        A student is moved to another period
        """
        self.ps.test_updates['name'] = 't1.42.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.008', '8265']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="change-period"]').click()
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        element = self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//a')
        period_name = element.text
        element.click()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//li/a[contains(text(),"'+period_name+'")]').click()
        self.teacher.driver.find_element(
            By.XPATH, '//td[contains(text(),"%s")]' % student_name)

        self.ps.test_updates['passed'] = True

    # Case C8266 - 009 - Teacher | Drop a student
    @pytest.mark.skipif(str(8266) not in TESTS, reason='Excluded')
    def test_teacher_drop_a_student_8266(self):
        """Drop a student.

        Steps:
        Click on the user menu in the upper right corner of the page
        Click "Course Roster"
        Click "Drop" for a student under the Roster section
        Click "Drop" in the box that pops up

        Expected Result:
        A student is dropped from the course and
        is put under the Dropped Students section
        """
        self.ps.test_updates['name'] = 't1.42.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.009', '8266']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="drop-student"]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        self.teacher.sleep(1)
        # check that student was droped
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"dropped-students")]' +
            '//td[contains(text(),"%s")]' % student_name
        )

        self.ps.test_updates['passed'] = True

    # Case C8267 - 010 - Teacher | Readd a dropped student
    @pytest.mark.skipif(str(8267) not in TESTS, reason='Excluded')
    def test_teacher_readd_a_dropped_student_8267(self):
        """Readd a dropped student.

        Steps:
        Click "Add Back to Active Roster" for a student under
            the Dropped Students section
        Click "Add" on the box that pops up

        Expected Result:
        A student is added back to the course
        """
        self.ps.test_updates['name'] = 't1.42.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.010', '8267']
        self.ps.test_updates['passed'] = False

        # drop a student (to make sure there is someone to add back)
        student_name = self.teacher.find(
            By.XPATH, '//div[@class="roster"]//td').text
        self.teacher.find(
            By.XPATH, '//a[@aria-describedby="drop-student"]').click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        self.teacher.sleep(1)
        # add a student back (not necessarily the same student)
        element = self.teacher.find(
            By.XPATH, '//div[contains(@class,"dropped-students")]' +
            '//span[contains(text(),"Add Back to Active Roster")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', element)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        element.click()
        self.teacher.find(
            By.XPATH, '//div[@class="popover-content"]//button').click()
        # check that student was added back
        self.teacher.find(
            By.XPATH,
            '//div[@class="roster"]//td[contains(text(),"%s")]' % student_name)

        self.ps.test_updates['passed'] = True

    # Case C58356 - 011 - Teacher | Unarchive an empty period
    @pytest.mark.skipif(str(58356) not in TESTS, reason='Excluded')
    def test_teacher_unarchive_an_empty_period_58356(self):
        """Unarchive an empty period.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account [ teacher001 ] and password in the boxes
        Click on the 'Sign in' button
        If the user has more than one course, click on a Tutor course name
        Click on the user menu in the upper right corner of the page
        Click "Course Settings and Roster"
        Click "View Archived Period(s)"
        Click Unarchived period next to selected course

        Expected Result:
        Period is made active.
        """
        self.ps.test_updates['name'] = 't1.42.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.011', '58356']
        self.ps.test_updates['passed'] = False

        # create a period
        period_name = 'automated_011_' + str(randint(0, 999))
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"add-period")]//button').click()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//input[contains(@class,"form-control")]')
            )
        ).send_keys(period_name)
        self.teacher.find(
            By.XPATH,
            '//button[contains(@class,"edit-period-confirm")]'
        ).click()
        self.teacher.sleep(1)
        # archive the period
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"'+period_name+'")]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//a[contains(@class,"archive-period")]').click()
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"popover-content")]' +
            '//button[contains(@class,"archive")]').click()
        self.teacher.sleep(2)
        archived_period = self.teacher.find_all(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')
        assert(len(archived_period) == 0), 'period not archived'
        # unarchive the period
        self.teacher.find(
            By.XPATH, '//div[contains(@class,"view-archived-periods")]//button'
        ).click()
        self.teacher.sleep(1)
        rows = self.teacher.find_all(
            By.XPATH, '//div[@class="modal-content"]//tbody/tr')
        for row in rows:
            temp_name = row.find_element(By.XPATH, "./td[1]").text
            if temp_name == period_name:
                row.find_element(
                    By.XPATH,
                    "./td[3]//button[contains(@class,'unarchive-section')]"
                ).click()
                self.teacher.find(
                    By.XPATH,
                    '//div[@class="modal-content"]//button[@class="close"]'
                ).click()
                break
        # check that period is no longer archived
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"'+period_name+'")]')

        self.ps.test_updates['passed'] = True
class TestCreateNewQuestionAndAssignmentTypes(unittest.TestCase):
    """T2.12 - Create New Question and Assignment Types."""
    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.student = Student(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)
        self.student = None
        try:
            self.teacher.delete()
        except:
            pass

    # 14739 - 001 - Teacher | Vocabulary question is a question type
    @pytest.mark.skipif(str(14739) not in TESTS, reason='Excluded')
    def test_teacher_vocabulary_question_is_a_question_type_14739(self):
        """Vocabulary question is a question type.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher account in the username and password text boxes
        Click on the 'Sign in' button
        Click "Write a new exercise"
        Click "New Vocabulary Term"

        Expected Result:
        The user is presented with a page where a new vocabulary question can
        be created
        """
        self.ps.test_updates['name'] = 't2.12.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.001', '14739']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get("https://exercises-qa.openstax.org/")
        # login
        self.teacher.find(
            By.XPATH,
            '//div[@id="account-bar-content"]//a[text()="Sign in"]').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)
        self.teacher.find(By.XPATH, '//button[text()="Sign in"]').click()
        # create new vocab
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.XPATH, '//a[@href="/exercises/new"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="New Vocabulary Term"]'))).click()
        assert('/vocabulary/new' in self.teacher.current_url()), \
            'not at new vocab page'

        self.ps.test_updates['passed'] = True

    # 14741 - 002 - Teacher | True/False is a question type
    @pytest.mark.skipif(str(14741) not in TESTS, reason='Excluded')
    def test_teacher_truefalse_is_a_question_type_14741(self):
        """True/False is a question type.

        Steps:
        Click "Write a new exercise"
        Click on the "True/False" radio button

        Expected Result:
        The user is presented with a page where a True/False question can be
        created
        """
        self.ps.test_updates['name'] = 't2.12.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.002', '14741']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get("https://exercises-qa.openstax.org/")
        # login
        self.teacher.find(
            By.XPATH,
            '//div[@id="account-bar-content"]//a[text()="Sign in"]').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)
        self.teacher.find(By.XPATH, '//button[text()="Sign in"]').click()
        # create new vocab
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.XPATH, '//a[@href="/exercises/new"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//input[@label="True/False"]'))).click()
        self.teacher.find(By.XPATH, '//span[text()="True/False"]')
        self.ps.test_updates['passed'] = True

    # possibly changed implementation on site
    # no info icon found
    # 14742 - 003 - System | Display embedded videos with attribution and link
    # back to author
    @pytest.mark.skipif(str(14742) not in TESTS, reason='Excluded')
    def test_system_display_embedded_videos_with_attribution_14742(self):
        """Display embedded videos with attribution and a link back to author.

        Steps:
        Go to Tutor
        Click Login
        Sign in as student01
        Click "HS AP Physics LG"
        Click on a homework assignment
        Click through it until you get to a video
        Click on the info icon on the video

        Expected Result:
        Attribution and links are displayed
        """
        self.ps.test_updates['name'] = 't2.12.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.003', '14742']
        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

    # NOT DONE
    # create hw helper still not working
    # but works for manually created assignemnt, add assignemnt commented out
    # 14743 - 004 - Teacher | Each part of a multi-part question counts as a
    # seperate problem when scored
    @pytest.mark.skipif(str(14743) not in TESTS, reason='Excluded')
    def test_teacher_each_part_of_a_multipart_question_counts_as_14743(self):
        """Multi-part questions count as seperate problems when scored.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Log in as teacher03
        Click "College Introduction to Sociology"
        Go to "Student Scores"
        Pick a homework that has multipart question
        Click "Review"

        Expected Result:
        There is a breadcrumb for each part of a multipart question
        """
        self.ps.test_updates['name'] = 't2.12.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.004', '14743']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # create a hw with a multi part question, and gice it a randomized name
        # ID: 12061@6 is multi part
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]').click()
        assignment_name = "homework-%s" % randint(100, 999)
        today = datetime.date.today()
        begin = (today + datetime.timedelta(days=0)).strftime('%m/%d/%Y')
        end = (today + datetime.timedelta(days=100)).strftime('%m/%d/%Y')
        self.teacher.add_assignment(assignment='homework',
                                    args={
                                        'title': assignment_name,
                                        'description': 'description',
                                        'periods': {
                                            'all': (begin, end)
                                        },
                                        'problems': {
                                            '1.1': ['12024@10'],
                                        },
                                        'status': 'publish',
                                    })
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Student Scores').click()
        self.teacher.page.wait_for_page_load()
        # can just click the first review because assignemnt just created
        # and should be the most recent one
        self.teacher.find(By.LINK_TEXT, 'Review').click()
        cards = self.teacher.find_all(By.XPATH,
                                      '//div[contains(@class,"card-body")]')
        questions = self.teacher.find_all(
            By.XPATH, '//div[contains(@class,"openstax-question")]')
        breadcrumbs = self.teacher.find_all(
            By.XPATH, '//span[contains(@class,"openstax-breadcrumb")]')
        assert(len(questions) == len(breadcrumbs)), \
            'breadcrumbs and questions not equal'
        assert(len(cards) < len(breadcrumbs)), \
            'multipart question card has multiple questions,' + \
            'not matching up with  breadcrumbs'

        self.ps.test_updates['passed'] = True

    # NOT DONE
    # same issue as above w/ add_homework helper
    # but works for manually created assignemnt
    # (add assignemnt gets commented out, manual assignemnt name added)
    # 14744 - 005 - Student | Each part of a multi-part question counts as a
    # seperate problem when scored
    @pytest.mark.skipif(str(14744) not in TESTS, reason='Excluded')
    def test_student_each_part_of_a_multipart_question_counts_as_14744(self):
        """Multi-part questions count as seperate problems when scored.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Log in as abarnes
        Click "College Introduction to Sociology"
        Click on a homework assignment
        Go through the questions

        Expected Result:
        There is a breadcrumb for each part in the multipart question and the
        progress/score is out of the total number of questions, rather than
        counting the multipart question as one question
        """
        self.ps.test_updates['name'] = 't2.12.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.005', '14744']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # create a hw with a multi part question, and give it a randomized name
        # ID: 12252@5 is multi part
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]').click()
        assignment_name = "homework-%s" % randint(100, 999)
        today = datetime.date.today()
        begin = (today + datetime.timedelta(days=0)).strftime('%m/%d/%Y')
        end = (today + datetime.timedelta(days=100)).strftime('%m/%d/%Y')
        self.teacher.add_assignment(assignment='homework',
                                    args={
                                        'title': assignment_name,
                                        'description': 'description',
                                        'periods': {
                                            'all': (begin, end)
                                        },
                                        'problems': {
                                            '1.1': ['12024@10'],
                                        },
                                        'status': 'publish',
                                    })
        self.teacher.logout()
        # assignemnt name put here for manual testing
        # assignment_name = 'hw w/ video and multi part question'
        # login as student and go to same class
        self.student.login()
        self.teacher.find(
            By.XPATH, '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]').click()
        self.student.page.wait_for_page_load()
        # go to assignment (find my assignemnt_name)
        self.student.find(
            By.XPATH, '//a[contains(@class,"homework workable")]' +
            '//span[text()="' + assignment_name + '"]').click()
        # go through all questions
        breadcrumbs = self.teacher.find_all(
            By.XPATH, '//span[contains(@class,"openstax-breadcrumb")' +
            ' and not(contains(@class,"intro"))' +
            ' and not(contains(@class,"personalized"))'
            ' and not(contains(@class,"end"))]')
        total_questions = 0
        found_multipart = False
        i = 0
        while i < len(breadcrumbs):
            breadcrumbs[i].click()
            try:
                self.student.find(By.XPATH,
                                  '//span[text()="Multi-part question"]')
                found_multipart = True
                questions = self.teacher.find_all(
                    By.XPATH, '//div[contains(@class,"openstax-question")]')
                total_questions += len(questions)
                i += len(questions)
            except NoSuchElementException:
                i += 1
                questions = self.teacher.find_all(
                    By.XPATH, '//div[contains(@class,"openstax-question")]')
                total_questions += len(questions)
        # check that everything worked out
        assert (found_multipart), 'no multipart question found'
        assert(total_questions == len(breadcrumbs)), \
            'breadcrumbs and questions not equal'

        self.ps.test_updates['passed'] = True
Esempio n. 3
0
class TestTrainingAndSupportingTeachersAndStudents(unittest.TestCase):
    """CC1.14 - Training and Supporting Teachers and Students."""
    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.student = Student(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)
        self.student = None
        try:
            self.teacher.delete()
        except:
            pass

    # Case C7704 - 001 - System | Concept Coach Zendesk is web-accessible
    @pytest.mark.skipif(str(7704) not in TESTS, reason='Excluded')
    def test_system_concept_coach_zendesk_is_web_accessible_7704(self):
        """Concept Coach Zendesk is web-accesible.

        Steps:
        Log in to Tutor as teacher
        If more then one course, click on a concept coach course
        In user menu in top right of header, click 'Get Help'

        Expected Result:
        In a new window or tab, zendesk help is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.001', '7704']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        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(),"Concept Coach Help Center")]')
        assert ('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7705 - 002 - Teacher | Can access user support
    @pytest.mark.skipif(str(7705) not in TESTS, reason='Excluded')
    def test_teacher_can_access_user_support_7705(self):
        """Can access user support.

        Steps:
        Click on the user menu
        Click on the Get Help option

        Expected Result:
        In a new tab or window Zendesk is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.002', '7705']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        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(),"Concept Coach Help Center")]')
        assert ('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7706 - 003 - Student | Can access user support
    @pytest.mark.skipif(str(7706) not in TESTS, reason='Excluded')
    def test_student_can_access_user_support_7706(self):
        """Can access user support.

        Steps:
        Click on the user menu
        Click on the Get Help option

        Expected Result:
        In a new tab or window zendesk is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.003', '7706']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]')
        assert ('support' in self.student.current_url()), 'not at help center'
        self.ps.test_updates['passed'] = True

    # Case C7707 - 004 - Non-user | Submit support questions
    @pytest.mark.skipif(str(7707) not in TESTS, reason='Excluded')
    def test_nonuser_submit_support_questions_7707(self):
        """Submit support questions.

        Steps:
        Go to the Concept Coach landing page
        click support in the header
        enter text into the search box
        click contact us
        fillout form
        click Submit

        Expected Result:
        'Message sent' displayed in help box
        """
        self.ps.test_updates['name'] = 'cc1.14.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.004', '7707']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.sleep(1)
        # number hardcoded because condenses at different size than tutor
        if self.teacher.driver.get_window_size()['width'] < 1105:
            element = self.teacher.wait.until(
                expect.visibility_of_element_located(
                    (By.XPATH, '//label[@for="mobileNavToggle"]')))
            actions = ActionChains(self.teacher.driver)
            # use action chain because it is clicking to the wrong elemnt
            actions.move_to_element(element)
            actions.click()
            actions.perform()
        support = self.teacher.find(By.LINK_TEXT, 'support')
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(support)
        actions.click()
        actions.perform()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'searchAskInput').send_keys('fake_question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.find(By.LINK_TEXT, 'Contact Us').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:firstName")]').send_keys('qa')
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:lastName")]').send_keys(
                'test')
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:email")]').send_keys(
                '*****@*****.**')
        self.teacher.find(By.XPATH,
                          '//div[@class="submit-container"]//input').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')))
        self.ps.test_updates['passed'] = True

    # Case C7708 - 005 - Teacher | Submit support questions
    @pytest.mark.skipif(str(7708) not in TESTS, reason='Excluded')
    def test_teacher_submit_support_questions_7708(self):
        """Submit support questions.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Submit a request"
        Fill out all the necessary text fields
        Click "Submit"

        Expected Result:
        The user submits support questions
        """
        self.ps.test_updates['name'] = 'cc1.14.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.005', '7708']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        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(),"Concept Coach Help Center")]')
        assert ('support' in self.teacher.current_url()), 'not at help center'
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'searchAskInput').send_keys('fake_question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.find(By.LINK_TEXT, 'Contact Us').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:firstName")]').send_keys('qa')
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:lastName")]').send_keys(
                'test')
        self.teacher.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:email")]').send_keys(
                '*****@*****.**')
        self.teacher.find(By.XPATH,
                          '//div[@class="submit-container"]//input').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')))
        self.ps.test_updates['passed'] = True

    # Case C7709 - 006 - Student | Submit support questions
    @pytest.mark.skipif(str(7709) not in TESTS, reason='Excluded')
    def test_student_submit_support_questions_7709(self):
        """Submit support questions.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the student user account in the username and password text boxes
        Click on the 'Sign in' button
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Submit a request"
        Fill out all the necessary text fields
        Click "Submit"

        Expected Result:
        The user submits support questions
        """
        self.ps.test_updates['name'] = 'cc1.14.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.006', '7709']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]')
        assert ('support' in self.student.current_url()), 'not at help center'
        self.student.page.wait_for_page_load()
        self.student.find(By.ID, 'searchAskInput').send_keys('fake_question')
        self.student.find(By.ID, 'searchAskButton').click()
        self.student.find(By.LINK_TEXT, 'Contact Us').click()
        self.student.page.wait_for_page_load()
        self.student.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:firstName")]').send_keys('qa')
        self.student.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:lastName")]').send_keys(
                'test')
        self.student.find(
            By.XPATH,
            '//input[contains(@id,"contactUsForm:email")]').send_keys(
                '*****@*****.**')
        self.student.find(By.XPATH,
                          '//div[@class="submit-container"]//input').click()
        self.student.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')))

        self.ps.test_updates['passed'] = True

    # Case C7710 - 007 - Teacher | View instructions on how to use CC
    @pytest.mark.skipif(str(7710) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_on_how_to_use_cc_7710(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Getting Started Guide"
        * Click on the pdf link
            OR
        * Click "Getting Started" from the user menu

        Expected Result:
        The user is presented with a guide to use CC
        """
        self.ps.test_updates['name'] = 'cc1.14.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.007', '7710']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Getting Started').click()
        self.teacher.find(By.XPATH,
                          '//h3[contains(text(),"Getting Started")]').click()
        assert ('help' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7711 - 008 - Student | View instructions on how to use CC
    @pytest.mark.skipif(str(7711) not in TESTS, reason='Excluded')
    def test_student_view_instructions_on_how_to_use_cc_7711(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the student user account in the username and password text boxes
        Click on the 'Sign in' button
        Click the user menu in the right corner of the header
        Click "Get Help"
        Scroll down to the questions under "Students"

        Expected Result:
        The user is presented with instructions on how to use CC
        """
        self.ps.test_updates['name'] = 'cc1.14.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.008', '7711']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]')
        assert ('support' in self.student.current_url()), 'not at help center'
        self.ps.test_updates['passed'] = True

    # Case C7712 - 009 - Teacher | View instructions on how to assign CC
    @pytest.mark.skipif(str(7712) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_on_how_to_assign_cc_7712(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"

        Expected Result:
        Taken to Zendesk in a new window or tab
        Assorted help is displayed
        """
        self.ps.test_updates['name'] = 'cc1.14.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.009', '7712']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        # change to window with help center
        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(),"Concept Coach Help Center")]')
        assert ('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7713 - 010 - Student | Get help during account registration
    @pytest.mark.skipif(str(7713) not in TESTS, reason='Excluded')
    def test_student_get_help_during_account_registration_7713(self):
        """View instructions on how to use Concept Coach.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.14.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.010', '7713']
        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 C7714 - 011 - Teacher | View instructions for Legacy users
    # transitioning to Concept Coach
    @pytest.mark.skipif(str(7714) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_for_legacy_users_transition_7714(self):
        """View instructions for Legacy users transitioning to Concept Coach.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.14.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.14', 'cc1.14.011', '7714']
        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 TestTrainingAndSupportingTeachersAndStudents(unittest.TestCase):
    """CC1.14 - Training and Supporting Teachers and Students."""

    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.student = Student(
            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
        )
        self.student = None
        try:
            self.teacher.delete()
        except:
            pass

    # Case C7704 - 001 - System | Concept Coach Zendesk is web-accessible
    @pytest.mark.skipif(str(7704) not in TESTS, reason='Excluded')
    def test_system_concept_coach_zendesk_is_web_accessible_7704(self):
        """Concept Coach Zendesk is web-accesible.

        Steps:
        Log in to Tutor as teacher
        If more then one course, click on a concept coach course
        In user menu in top right of header, click 'Get Help'

        Expected Result:
        In a new window or tab, zendesk help is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.001',
            '7704'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        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(),"Concept Coach Help Center")]'
        )
        assert('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7705 - 002 - Teacher | Can access user support
    @pytest.mark.skipif(str(7705) not in TESTS, reason='Excluded')
    def test_teacher_can_access_user_support_7705(self):
        """Can access user support.

        Steps:
        Click on the user menu
        Click on the Get Help option

        Expected Result:
        In a new tab or window Zendesk is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.002',
            '7705'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        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(),"Concept Coach Help Center")]'
        )
        assert('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7706 - 003 - Student | Can access user support
    @pytest.mark.skipif(str(7706) not in TESTS, reason='Excluded')
    def test_student_can_access_user_support_7706(self):
        """Can access user support.

        Steps:
        Click on the user menu
        Click on the Get Help option

        Expected Result:
        In a new tab or window zendesk is opened
        """
        self.ps.test_updates['name'] = 'cc1.14.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.003',
            '7706'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        )
        assert('support' in self.student.current_url()), 'not at help center'
        self.ps.test_updates['passed'] = True

    # Case C7707 - 004 - Non-user | Submit support questions
    @pytest.mark.skipif(str(7707) not in TESTS, reason='Excluded')
    def test_nonuser_submit_support_questions_7707(self):
        """Submit support questions.

        Steps:
        Go to the Concept Coach landing page
        click support in the header
        enter text into the search box
        click contact us
        fillout form
        click Submit

        Expected Result:
        'Message sent' displayed in help box
        """
        self.ps.test_updates['name'] = 'cc1.14.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.004',
            '7707'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.sleep(1)
        # number hardcoded because condenses at different size than tutor
        if self.teacher.driver.get_window_size()['width'] < 1105:
            element = self.teacher.wait.until(
                expect.visibility_of_element_located(
                    (By.XPATH, '//label[@for="mobileNavToggle"]')
                )
            )
            actions = ActionChains(self.teacher.driver)
            # use action chain because it is clicking to the wrong elemnt
            actions.move_to_element(element)
            actions.click()
            actions.perform()
        support = self.teacher.find(
            By.LINK_TEXT, 'support'
        )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(support)
        actions.click()
        actions.perform()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'searchAskInput'
        ).send_keys('fake_question')
        self.teacher.find(
            By.ID, 'searchAskButton'
        ).click()
        self.teacher.find(
            By.LINK_TEXT, 'Contact Us'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:firstName")]'
        ).send_keys('qa')
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:lastName")]'
        ).send_keys('test')
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:email")]'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.XPATH, '//div[@class="submit-container"]//input'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7708 - 005 - Teacher | Submit support questions
    @pytest.mark.skipif(str(7708) not in TESTS, reason='Excluded')
    def test_teacher_submit_support_questions_7708(self):
        """Submit support questions.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Submit a request"
        Fill out all the necessary text fields
        Click "Submit"

        Expected Result:
        The user submits support questions
        """
        self.ps.test_updates['name'] = 'cc1.14.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.005',
            '7708'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        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(),"Concept Coach Help Center")]'
        )
        assert('support' in self.teacher.current_url()), 'not at help center'
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'searchAskInput'
        ).send_keys('fake_question')
        self.teacher.find(
            By.ID, 'searchAskButton'
        ).click()
        self.teacher.find(
            By.LINK_TEXT, 'Contact Us'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:firstName")]'
        ).send_keys('qa')
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:lastName")]'
        ).send_keys('test')
        self.teacher.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:email")]'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.XPATH, '//div[@class="submit-container"]//input'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7709 - 006 - Student | Submit support questions
    @pytest.mark.skipif(str(7709) not in TESTS, reason='Excluded')
    def test_student_submit_support_questions_7709(self):
        """Submit support questions.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the student user account in the username and password text boxes
        Click on the 'Sign in' button
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Submit a request"
        Fill out all the necessary text fields
        Click "Submit"

        Expected Result:
        The user submits support questions
        """
        self.ps.test_updates['name'] = 'cc1.14.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.006',
            '7709'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        )
        assert('support' in self.student.current_url()), 'not at help center'
        self.student.page.wait_for_page_load()
        self.student.find(
            By.ID, 'searchAskInput'
        ).send_keys('fake_question')
        self.student.find(
            By.ID, 'searchAskButton'
        ).click()
        self.student.find(
            By.LINK_TEXT, 'Contact Us'
        ).click()
        self.student.page.wait_for_page_load()
        self.student.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:firstName")]'
        ).send_keys('qa')
        self.student.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:lastName")]'
        ).send_keys('test')
        self.student.find(
            By.XPATH, '//input[contains(@id,"contactUsForm:email")]'
        ).send_keys('*****@*****.**')
        self.student.find(
            By.XPATH, '//div[@class="submit-container"]//input'
        ).click()
        self.student.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//p[contains(text(),"Thank you")]')
            )
        )

        self.ps.test_updates['passed'] = True

    # Case C7710 - 007 - Teacher | View instructions on how to use CC
    @pytest.mark.skipif(str(7710) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_on_how_to_use_cc_7710(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"
        Click "Getting Started Guide"
        * Click on the pdf link
            OR
        * Click "Getting Started" from the user menu

        Expected Result:
        The user is presented with a guide to use CC
        """
        self.ps.test_updates['name'] = 'cc1.14.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.007',
            '7710'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Getting Started'
        ).click()
        self.teacher.find(
            By.XPATH, '//h3[contains(text(),"Getting Started")]'
        ).click()
        assert('help' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7711 - 008 - Student | View instructions on how to use CC
    @pytest.mark.skipif(str(7711) not in TESTS, reason='Excluded')
    def test_student_view_instructions_on_how_to_use_cc_7711(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the student user account in the username and password text boxes
        Click on the 'Sign in' button
        Click the user menu in the right corner of the header
        Click "Get Help"
        Scroll down to the questions under "Students"

        Expected Result:
        The user is presented with instructions on how to use CC
        """
        self.ps.test_updates['name'] = 'cc1.14.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.008',
            '7711'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login()
        self.student.open_user_menu()
        self.student.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        )
        assert('support' in self.student.current_url()), 'not at help center'
        self.ps.test_updates['passed'] = True

    # Case C7712 - 009 - Teacher | View instructions on how to assign CC
    @pytest.mark.skipif(str(7712) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_on_how_to_assign_cc_7712(self):
        """View instructions on how to use Concept Coach.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher user account in the username and password text boxes
        Click on the 'Sign in' button
        If user has more than one course, click on a Concept Coach course
        Click the user menu in the right corner of the header
        Click "Get Help"

        Expected Result:
        Taken to Zendesk in a new window or tab
        Assorted help is displayed
        """
        self.ps.test_updates['name'] = 'cc1.14.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.009',
            '7712'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Get Help'
        ).click()
        # change to window with help center
        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(),"Concept Coach Help Center")]'
        )
        assert('support' in self.teacher.current_url()), 'not at help center'

        self.ps.test_updates['passed'] = True

    # Case C7713 - 010 - Student | Get help during account registration
    @pytest.mark.skipif(str(7713) not in TESTS, reason='Excluded')
    def test_student_get_help_during_account_registration_7713(self):
        """View instructions on how to use Concept Coach.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.14.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.010',
            '7713'
        ]
        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 C7714 - 011 - Teacher | View instructions for Legacy users
    # transitioning to Concept Coach
    @pytest.mark.skipif(str(7714) not in TESTS, reason='Excluded')
    def test_teacher_view_instructions_for_legacy_users_transition_7714(self):
        """View instructions for Legacy users transitioning to Concept Coach.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.14.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.14',
            'cc1.14.011',
            '7714'
        ]
        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 TestRecruitingTeachers(unittest.TestCase):
    """CC1.01 - Recruiting Teachers."""

    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.CONDENSED_WIDTH = 1105

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(
            job_id=str(self.teacher.driver.session_id),
            **self.ps.test_updates
        )
        try:
            self.teacher.delete()
        except:
            pass

    # Case C7751 - 001 - Admin | Recruitment and promo website is available
    @pytest.mark.skipif(str(7751) not in TESTS, reason='Excluded')
    def test_admin_recruitment_and_promo_website_is_available_7751(self):
        """Recruitment and promo website is available.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Recruitment website loads and renders
        """
        self.ps.test_updates['name'] = 'cc1.01.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.001',
            '7751'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()

        self.ps.test_updates['passed'] = True

    # Case C7752 - 002 - Teacher | Information about Concept Coach and the
    # pilot are available on the demo site
    @pytest.mark.skipif(str(7752) not in TESTS, reason='Excluded')
    def test_teacher_information_about_cc_is_available_on_demo_site_7752(self):
        """Information about CC and pilot are available on the demo site.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Page loads several sections describing Concept Coach
        """
        self.ps.test_updates['name'] = 'cc1.01.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.002',
            '7752'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'who-we-are')

        self.ps.test_updates['passed'] = True

    # Case C7753 - 003 - Teacher | Can interact with a Concept Coach wire frame
    # for each subject
    @pytest.mark.skipif(str(7753) not in TESTS, reason='Excluded')
    def test_teacher_can_interact_with_a_cc_wire_frame_for_subjects_7753(self):
        """Can interact with a Concept Coach wire frame for each subject.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/)
        Hover over "demos" in the header
        Click "Interactice Demo"
        CLick on a Concept Coach book title

        Expected Result:
        A new tab or window opens rendering the demo content for the selected
        book
        """
        self.ps.test_updates['name'] = 'cc1.01.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.003',
            '7753'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH,
            '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        assert('http://cc.openstax.org/assets/demos/cc-mockup' in
               self.teacher.current_url()), \
            'not at demo book'
        self.ps.test_updates['passed'] = True

    # # NOT DONE
    # Case C7754 - 004 - Teacher | View a Concept Coach demo video
    @pytest.mark.skipif(str(7754) not in TESTS, reason='Excluded')
    def test_teacher_view_a_concept_coach_demo_video_7754(self):
        """View a Concept Coach demo video.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until an embedded video pane is displayed
        Click on the right-pointing arrow to play the video

        Expected Result:
        The video loads and plays
        """
        self.ps.test_updates['name'] = 'cc1.01.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.004',
            '7754'
        ]
        self.ps.test_updates['passed'] = False

        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH,
            '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup-physics")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(2)
        # self.teacher.find(
        #     By.XPATH, '//div[@id="player"]'
        # ).click()
        title = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(),"Inelastic Collisions")]')
            )
        )
        # self.teacher.wait.until(
        #     expect.presence_of_element_located(
        #         (By.ID, 'player')
        #     )
        # )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(title)
        actions.move_by_offset(0, 300)
        actions.click()
        actions.perform()
        self.teacher.sleep(2)
        self.teacher.find(
            By.XPATH,
            '//div[contains(@class,"playing-mode")]'
        )
        # actions.perform()
        self.teacher.find(
            By.XPATH,
            '//div[@id="player"]/div[contains(@class,"paused-mode")]'
        )

        self.ps.test_updates['passed'] = True

    # Case C7755 - 005 - Teacher | Sample exercise questions are seen in
    # the wire frames
    @pytest.mark.skipif(str(7755) not in TESTS, reason='Excluded')
    def test_teacher_sample_exercise_questions_are_in_wire_frames_7755(self):
        """Sample exercise questions are seen in the wire frames.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until the 'CONCEPT COACH' pane is displayed

        Expected Result:
        Demo exercises are rendered and can be answered along with showing
        feedback
        """
        self.ps.test_updates['name'] = 'cc1.01.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.005',
            '7755'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH,
            '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup-physics")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//span[contains(text(),"JUMP TO CONCEPT COACH")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//div[contains(@data-label,"q1-multiple-choice")]')
        self.teacher.sleep(2)
        answer = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@data-label,"choice-1b-text")]')
            )
        )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(answer)
        actions.click()
        actions.perform()
        self.teacher.find(
            By.XPATH, "//div[@data-label='State2']"
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 "//div[@data-label='q1-answer-b']//div[@data-label='next']")
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7756 - 006 - Teacher | Access Concept Coach help and support before
    # the teacher's course is created
    @pytest.mark.skipif(str(7756) not in TESTS, reason='Excluded')
    def test_teacher_access_cc_support_before_course_is_created_7756(self):
        """Access CC help and support before the teacher's course is created.

        Steps:
        Open the recruitment website ( http://cc.openstax.org/ )
        Click "Support" in the header

        Expected Result:
        A new tab opens with the CC Help Center
        """
        self.ps.test_updates['name'] = 'cc1.01.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.006',
            '7756'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        if self.teacher.driver.get_window_size()['width'] < \
                self.CONDENSED_WIDTH:
            self.teacher.wait.until(
                expect.visibility_of_element_located(
                    (By.XPATH, '//label[@for="mobileNavToggle" and ' +
                     'contains(@class,"fixed")]')
                )
            ).click()
            self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH, '//a[contains(text(),"support")]'
        ).click()
        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(),"Concept Coach Help Center")]'
        )

        self.ps.test_updates['passed'] = True

    # Case C7757 - 007 - Teacher | Teacher registers to use a CC course
    @pytest.mark.skipif(str(7757) not in TESTS, reason='Excluded')
    def test_teacher_teacher_registers_to_use_a_cc_course_7757(self):
        """Teacher registers to use a Concept Coach course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button

        Expected Result:
        Web form renders
        """
        self.ps.test_updates['name'] = 'cc1.01.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.007',
            '7757'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.ps.test_updates['passed'] = True

    # Case C7758 - 008 - Teacher | Teacher uses a web form to sign up for CC
    @pytest.mark.skipif(str(7758) not in TESTS, reason='Excluded')
    def test_teacher_teacher_uses_a_web_form_to_sign_up_for_cc_7758(self):
        """Teacher uses a web form to sign up for Concept Coach.

        Steps:
        Teacher fills out the form

        Expected Result:
        Preconditions pass.
        User is presented with a confirmation message
        """
        self.ps.test_updates['name'] = 'cc1.01.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.008',
            '7758'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7759 - 009 - Teacher | Receive error messages if required fields on
    # the sign up form are blank
    @pytest.mark.skipif(str(7759) not in TESTS, reason='Excluded')
    def test_teacher_receive_error_messages_if_required_fields_are_7759(self):
        """Receive error messages if required fields on the sign up form are blank.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Submit the form without changing any of the text fields

        Expected Result:
        Receive 'Please fill out this field' error messages in red for
        each blank required field
        """
        self.ps.test_updates['name'] = 'cc1.01.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.009',
            '7759'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        submit = self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', submit)
        self.teacher.sleep(0.5)
        submit.click()
        assert('/sign-up' in self.teacher.current_url()), \
            'moved from sign up when submitting with blank required fields'
        self.teacher.find(
            By.XPATH, '//div[contains(text(),"Please fill out this field.")]'
        )

        self.ps.test_updates['passed'] = True

    # Case C7760 - 010 - Teacher | Submit a form to supply required course info
    @pytest.mark.skipif(str(7760) not in TESTS, reason='Excluded')
    def test_teacher_submit_a_form_to_supply_required_course_info_7760(self):
        """Submit a form to supply required course information.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Web form submits
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.010',
            '7760'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        # choose a book!
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7761 - 011 - Teacher | Submit co-instructors, classes, names, etc.
    @pytest.mark.skipif(str(7761) not in TESTS, reason='Excluded')
    def test_teacher_submit_coinstructors_classes_names_etc_7761(self):
        """Submit co-instructors, classes, names and other data.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Click on the 'Co-Teaching class with a colleague?' circle button
        Enter the co-instructor's (or co-instructors') information
        Enter text into other fields concerning classe, names, etc.

        Expected Result:
        Input box exists for instructor information, class details and
        other data.
        The user is able to input information.
        """
        self.ps.test_updates['name'] = 'cc1.01.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.011',
            '7761'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        option = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@class="slide-checkbox"]/label')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', option)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        option.click()
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@id="coteachcontact"]/textarea')
            )
        )
        textarea.send_keys('co teacher info')
        self.ps.test_updates['passed'] = True

    # Case C7762 - 012 - Teacher | Select the textbook to use in the course
    @pytest.mark.skipif(str(7762) not in TESTS, reason='Excluded')
    def test_teacher_select_the_textbook_to_use_in_the_course_7762(self):
        """Select the textbook to use in the course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Select the course textbook from the 'Book' dropdown options

        Expected Result:
        Able to select any Concept Coach textbook
        """
        self.ps.test_updates['name'] = 'cc1.01.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.012',
            '7762'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        menu = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//span[@id="book-select"]' +
                 '//span[contains(@class,"select2-container--")]')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        book = self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        )
        title = book.text
        book.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//span[contains(@title,"' + title + '") and ' +
            'contains(@class,"select2-selection__rendered")]'
        )
        self.ps.test_updates['passed'] = True

    # Case C7763 - 013 - Teacher | Indicate whether the teacher was recruited
    # by OpenStax
    @pytest.mark.skipif(str(7763) not in TESTS, reason='Excluded')
    def test_teacher_indicate_whether_the_teacher_was_recruited_by_7763(self):
        """Indicate if the teacher was or was not recruited by OpenStax.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button ( http://cc.openstax.org/sign-up )
        Enter recruitment information into the 'Anything else we need to know?'
        text box

        Expected Result:
        Able to input recruitment information
        """
        self.ps.test_updates['name'] = 'cc1.01.013' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.013',
            '7763'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//textarea[@placeholder="Feedback"]')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', textarea)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        textarea.send_keys('recuitment info')
        self.ps.test_updates['passed'] = True

    # Case C7764 - 014 - Teacher | Presented a thank you page after registering
    # to use Concept Coach
    @pytest.mark.skipif(str(7764) not in TESTS, reason='Excluded')
    def test_teacher_presented_a_thank_you_page_after_registering_7764(self):
        """Presented a thank you page after registering to use Concept Coach.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.014' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.014',
            '7764'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7765 - 015 - Teacher | Sign up for an OpenStax Accounts username
    @pytest.mark.skipif(str(7765) not in TESTS, reason='Excluded')
    def test_teacher_sign_up_for_an_openstax_accounts_username_7765(self):
        """Sign up for an OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.015' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.015',
            '7765'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7770 - 020 - Admin | Add co-instructors to a course
    @pytest.mark.skipif(str(7770) not in TESTS, reason='Excluded')
    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
        self.teacher.login(
            username=os.getenv('ADMIN_USER'),
            password=os.getenv('ADMIN_PASSWORD'))
        self.teacher.open_user_menu()
        self.teacher.find(
            By.XPATH, '//a[@role="menuitem" and contains(text(),"Admin")]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Course Organization')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Courses')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Edit')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Teachers')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'course_teacher')
            )
        ).send_keys('teacher0')
        element = self.teacher.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)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//td[contains(text(),"' + teacher_name + '")]')
            )
        )

        self.ps.test_updates['passed'] = True

    # Case C7771 - 021 - Teacher | Login with an Existing OpenStax Account
    @pytest.mark.skipif(str(7771) not in TESTS, reason='Excluded')
    def test_teacher_login_with_an_existing_openstax_account_7771(self):
        """Log in with an Existing OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on faculty login
        You are redirected to the accounts page.
        Enter a username and password
        click on Login.

        Expected Result:
        Login should be successful. It should take you to the teacher course
        picker/dashboard page.
        """
        self.ps.test_updates['name'] = 'cc1.01.021' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.021',
            '7771'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        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 C7772 - 022 - Teacher | Access the Concept Coach course
    @pytest.mark.skipif(str(7772) not in TESTS, reason='Excluded')
    def test_teacher_access_the_cc_course_7772(self):
        """Access the Concept Coach course.

        Steps:
        Once you login you will be taken to a course picker page.
        Click on the course you want to check the dashboard

        Expected Result:
        At Concept Coach teacher dashboard
        """
        self.ps.test_updates['name'] = 'cc1.01.022' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.022',
            '7772'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        assert('cc-dashboard' in self.teacher.current_url()),\
            'Not taken to dashboard: %s' % self.teacher.current_url()

        self.ps.test_updates['passed'] = True

    # Case C7773 - 023 - Admin | Distribute access codes for the course
    @pytest.mark.skipif(str(7773) not in TESTS, reason='Excluded')
    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

    # Case C7774 - 024 - Teacher | Access CC help and support during the course
    @pytest.mark.skipif(str(7774) not in TESTS, reason='Excluded')
    def test_teacher_acccess_cc_help_and_support_during_the_course_7774(self):
        """Access Concept Coach help and support during the course.

        Steps:
        Login as teacher
        Click on the course name
        On dashboard click on the name of the teacher
        It drops down and displays several options.
        Click on Get Help

        Expected Result:
        It should open a new tab which shows the openstax.force.com
        """
        self.ps.test_updates['name'] = 'cc1.01.024' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.024',
            '7774'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//a[contains(@href,"/cc-dashboard/")]'
        ).click()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.PARTIAL_LINK_TEXT, "Get Help"
        ).click()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        ).click()

        self.ps.test_updates['passed'] = True

    # Case C7775 - 025 - Teacher | Access CC help and support after course ends
    @pytest.mark.skipif(str(7775) not in TESTS, reason='Excluded')
    def test_teacher_access_cc_help_and_support_after_course_ends_7775(self):
        """Access Concept Coach help and support after the end of the course.

        Steps:
        Login as teacher
        Click on the course name
        On dashboard click on the name of the teacher
        It drops down and displays several options.
        Click on Get Help

        Expected Result:
        It should open a new tab which shows the CC help center
        """
        self.ps.test_updates['name'] = 'cc1.01.025' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.025',
            '7775'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.open_user_menu()
        self.teacher.find(
            By.PARTIAL_LINK_TEXT, "Get Help"
        ).click()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        ).click()

        self.ps.test_updates['passed'] = True
class TestCreateNewQuestionAndAssignmentTypes(unittest.TestCase):
    """T2.12 - Create New Question and Assignment Types."""

    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.student = Student(
            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
        )
        self.student = None
        try:
            self.teacher.delete()
        except:
            pass

    # 14739 - 001 - Teacher | Vocabulary question is a question type
    @pytest.mark.skipif(str(14739) not in TESTS, reason='Excluded')
    def test_teacher_vocabulary_question_is_a_question_type_14739(self):
        """Vocabulary question is a question type.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the teacher account in the username and password text boxes
        Click on the 'Sign in' button
        Click "Write a new exercise"
        Click "New Vocabulary Term"

        Expected Result:
        The user is presented with a page where a new vocabulary question can
        be created
        """
        self.ps.test_updates['name'] = 't2.12.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.001', '14739']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get("https://exercises-qa.openstax.org/")
        # login
        self.teacher.find(
            By.XPATH, '//div[@id="account-bar-content"]//a[text()="Sign in"]'
        ).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)
        self.teacher.find(
            By.XPATH, '//button[text()="Sign in"]'
        ).click()
        # create new vocab
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//a[@href="/exercises/new"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="New Vocabulary Term"]')
            )
        ).click()
        assert('/vocabulary/new' in self.teacher.current_url()), \
            'not at new vocab page'

        self.ps.test_updates['passed'] = True

    # 14741 - 002 - Teacher | True/False is a question type
    @pytest.mark.skipif(str(14741) not in TESTS, reason='Excluded')
    def test_teacher_truefalse_is_a_question_type_14741(self):
        """True/False is a question type.

        Steps:
        Click "Write a new exercise"
        Click on the "True/False" radio button

        Expected Result:
        The user is presented with a page where a True/False question can be
        created
        """
        self.ps.test_updates['name'] = 't2.12.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.002', '14741']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get("https://exercises-qa.openstax.org/")
        # login
        self.teacher.find(
            By.XPATH, '//div[@id="account-bar-content"]//a[text()="Sign in"]'
        ).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)
        self.teacher.find(
            By.XPATH, '//button[text()="Sign in"]'
        ).click()
        # create new vocab
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//a[@href="/exercises/new"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//input[@label="True/False"]')
            )
        ).click()
        self.teacher.find(
            By.XPATH, '//span[text()="True/False"]'
        )
        self.ps.test_updates['passed'] = True

    # possibly changed implementation on site
    # no info icon found
    # 14742 - 003 - System | Display embedded videos with attribution and link
    # back to author
    @pytest.mark.skipif(str(14742) not in TESTS, reason='Excluded')
    def test_system_display_embedded_videos_with_attribution_14742(self):
        """Display embedded videos with attribution and a link back to author.

        Steps:
        Go to Tutor
        Click Login
        Sign in as student01
        Click "HS AP Physics LG"
        Click on a homework assignment
        Click through it until you get to a video
        Click on the info icon on the video

        Expected Result:
        Attribution and links are displayed
        """
        self.ps.test_updates['name'] = 't2.12.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.003', '14742']
        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

    # NOT DONE
    # create hw helper still not working
    # but works for manually created assignemnt, add assignemnt commented out
    # 14743 - 004 - Teacher | Each part of a multi-part question counts as a
    # seperate problem when scored
    @pytest.mark.skipif(str(14743) not in TESTS, reason='Excluded')
    def test_teacher_each_part_of_a_multipart_question_counts_as_14743(self):
        """Multi-part questions count as seperate problems when scored.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Log in as teacher03
        Click "College Introduction to Sociology"
        Go to "Student Scores"
        Pick a homework that has multipart question
        Click "Review"

        Expected Result:
        There is a breadcrumb for each part of a multipart question
        """
        self.ps.test_updates['name'] = 't2.12.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.004', '14743']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # create a hw with a multi part question, and gice it a randomized name
        # ID: 12061@6 is multi part
        self.teacher.login()
        self.teacher.find(
            By.XPATH,
            '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]'
        ).click()
        assignment_name = "homework-%s" % randint(100, 999)
        today = datetime.date.today()
        begin = (today + datetime.timedelta(days=0)).strftime('%m/%d/%Y')
        end = (today + datetime.timedelta(days=100)).strftime('%m/%d/%Y')
        self.teacher.add_assignment(
            assignment='homework',
            args={
                'title': assignment_name,
                'description': 'description',
                'periods': {'all': (begin, end)},
                'problems': {'1.1': ['12024@10'], },
                'status': 'publish',
            }
        )
        self.teacher.open_user_menu()
        self.teacher.find(
            By.LINK_TEXT, 'Student Scores'
        ).click()
        self.teacher.page.wait_for_page_load()
        # can just click the first review because assignemnt just created
        # and should be the most recent one
        self.teacher.find(
            By.LINK_TEXT, 'Review'
        ).click()
        cards = self.teacher.find_all(
            By.XPATH, '//div[contains(@class,"card-body")]')
        questions = self.teacher.find_all(
            By.XPATH, '//div[contains(@class,"openstax-question")]')
        breadcrumbs = self.teacher.find_all(
            By.XPATH, '//span[contains(@class,"openstax-breadcrumb")]')
        assert(len(questions) == len(breadcrumbs)), \
            'breadcrumbs and questions not equal'
        assert(len(cards) < len(breadcrumbs)), \
            'multipart question card has multiple questions,' + \
            'not matching up with  breadcrumbs'

        self.ps.test_updates['passed'] = True

    # NOT DONE
    # same issue as above w/ add_homework helper
    # but works for manually created assignemnt
    # (add assignemnt gets commented out, manual assignemnt name added)
    # 14744 - 005 - Student | Each part of a multi-part question counts as a
    # seperate problem when scored
    @pytest.mark.skipif(str(14744) not in TESTS, reason='Excluded')
    def test_student_each_part_of_a_multipart_question_counts_as_14744(self):
        """Multi-part questions count as seperate problems when scored.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Log in as abarnes
        Click "College Introduction to Sociology"
        Click on a homework assignment
        Go through the questions

        Expected Result:
        There is a breadcrumb for each part in the multipart question and the
        progress/score is out of the total number of questions, rather than
        counting the multipart question as one question
        """
        self.ps.test_updates['name'] = 't2.12.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.005', '14744']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # create a hw with a multi part question, and give it a randomized name
        # ID: 12252@5 is multi part
        self.teacher.login()
        self.teacher.find(
            By.XPATH,
            '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]'
        ).click()
        assignment_name = "homework-%s" % randint(100, 999)
        today = datetime.date.today()
        begin = (today + datetime.timedelta(days=0)).strftime('%m/%d/%Y')
        end = (today + datetime.timedelta(days=100)).strftime('%m/%d/%Y')
        self.teacher.add_assignment(
            assignment='homework',
            args={
                'title': assignment_name,
                'description': 'description',
                'periods': {'all': (begin, end)},
                'problems': {'1.1': ['12024@10'], },
                'status': 'publish',
            }
        )
        self.teacher.logout()
        # assignemnt name put here for manual testing
        # assignment_name = 'hw w/ video and multi part question'
        # login as student and go to same class
        self.student.login()
        self.teacher.find(
            By.XPATH,
            '//div[@data-appearance="intro_sociology"]' +
            '//a[not(contains(@href,"/cc-dashboard"))]'
        ).click()
        self.student.page.wait_for_page_load()
        # go to assignment (find my assignemnt_name)
        self.student.find(
            By.XPATH,
            '//a[contains(@class,"homework workable")]' +
            '//span[text()="' + assignment_name + '"]'
        ).click()
        # go through all questions
        breadcrumbs = self.teacher.find_all(
            By.XPATH,
            '//span[contains(@class,"openstax-breadcrumb")' +
            ' and not(contains(@class,"intro"))' +
            ' and not(contains(@class,"personalized"))'
            ' and not(contains(@class,"end"))]')
        total_questions = 0
        found_multipart = False
        i = 0
        while i < len(breadcrumbs):
            breadcrumbs[i].click()
            try:
                self.student.find(
                    By.XPATH, '//span[text()="Multi-part question"]')
                found_multipart = True
                questions = self.teacher.find_all(
                    By.XPATH, '//div[contains(@class,"openstax-question")]')
                total_questions += len(questions)
                i += len(questions)
            except NoSuchElementException:
                i += 1
                questions = self.teacher.find_all(
                    By.XPATH, '//div[contains(@class,"openstax-question")]')
                total_questions += len(questions)
        # check that everything worked out
        assert(found_multipart), 'no multipart question found'
        assert(total_questions == len(breadcrumbs)), \
            'breadcrumbs and questions not equal'

        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 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 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 TestRecruitingTeachers(unittest.TestCase):
    """CC1.01 - Recruiting Teachers."""
    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.CONDENSED_WIDTH = 1105

    def tearDown(self):
        """Test destructor."""
        self.ps.update_job(job_id=str(self.teacher.driver.session_id),
                           **self.ps.test_updates)
        try:
            self.teacher.delete()
        except:
            pass

    # Case C7751 - 001 - Admin | Recruitment and promo website is available
    @pytest.mark.skipif(str(7751) not in TESTS, reason='Excluded')
    def test_admin_recruitment_and_promo_website_is_available_7751(self):
        """Recruitment and promo website is available.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Recruitment website loads and renders
        """
        self.ps.test_updates['name'] = 'cc1.01.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.001', '7751']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()

        self.ps.test_updates['passed'] = True

    # Case C7752 - 002 - Teacher | Information about Concept Coach and the
    # pilot are available on the demo site
    @pytest.mark.skipif(str(7752) not in TESTS, reason='Excluded')
    def test_teacher_information_about_cc_is_available_on_demo_site_7752(self):
        """Information about CC and pilot are available on the demo site.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Page loads several sections describing Concept Coach
        """
        self.ps.test_updates['name'] = 'cc1.01.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.002', '7752']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'who-we-are')

        self.ps.test_updates['passed'] = True

    # Case C7753 - 003 - Teacher | Can interact with a Concept Coach wire frame
    # for each subject
    @pytest.mark.skipif(str(7753) not in TESTS, reason='Excluded')
    def test_teacher_can_interact_with_a_cc_wire_frame_for_subjects_7753(self):
        """Can interact with a Concept Coach wire frame for each subject.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/)
        Hover over "demos" in the header
        Click "Interactice Demo"
        CLick on a Concept Coach book title

        Expected Result:
        A new tab or window opens rendering the demo content for the selected
        book
        """
        self.ps.test_updates['name'] = 'cc1.01.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.003', '7753']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH, '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        assert('http://cc.openstax.org/assets/demos/cc-mockup' in
               self.teacher.current_url()), \
            'not at demo book'
        self.ps.test_updates['passed'] = True

    # # NOT DONE
    # Case C7754 - 004 - Teacher | View a Concept Coach demo video
    @pytest.mark.skipif(str(7754) not in TESTS, reason='Excluded')
    def test_teacher_view_a_concept_coach_demo_video_7754(self):
        """View a Concept Coach demo video.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until an embedded video pane is displayed
        Click on the right-pointing arrow to play the video

        Expected Result:
        The video loads and plays
        """
        self.ps.test_updates['name'] = 'cc1.01.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.004', '7754']
        self.ps.test_updates['passed'] = False

        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH, '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup-physics")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(2)
        # self.teacher.find(
        #     By.XPATH, '//div[@id="player"]'
        # ).click()
        title = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(text(),"Inelastic Collisions")]')))
        # self.teacher.wait.until(
        #     expect.presence_of_element_located(
        #         (By.ID, 'player')
        #     )
        # )
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(title)
        actions.move_by_offset(0, 300)
        actions.click()
        actions.perform()
        self.teacher.sleep(2)
        self.teacher.find(By.XPATH, '//div[contains(@class,"playing-mode")]')
        # actions.perform()
        self.teacher.find(
            By.XPATH,
            '//div[@id="player"]/div[contains(@class,"paused-mode")]')

        self.ps.test_updates['passed'] = True

    # Case C7755 - 005 - Teacher | Sample exercise questions are seen in
    # the wire frames
    @pytest.mark.skipif(str(7755) not in TESTS, reason='Excluded')
    def test_teacher_sample_exercise_questions_are_in_wire_frames_7755(self):
        """Sample exercise questions are seen in the wire frames.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until the 'CONCEPT COACH' pane is displayed

        Expected Result:
        Demo exercises are rendered and can be answered along with showing
        feedback
        """
        self.ps.test_updates['name'] = 'cc1.01.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.005', '7755']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH, '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup-physics")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH,
            '//span[contains(text(),"JUMP TO CONCEPT COACH")]').click()
        self.teacher.find(By.XPATH,
                          '//div[contains(@data-label,"q1-multiple-choice")]')
        self.teacher.sleep(2)
        answer = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@data-label,"choice-1b-text")]')))
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(answer)
        actions.click()
        actions.perform()
        self.teacher.find(By.XPATH, "//div[@data-label='State2']").click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 "//div[@data-label='q1-answer-b']//div[@data-label='next']")))
        self.ps.test_updates['passed'] = True

    # Case C7756 - 006 - Teacher | Access Concept Coach help and support before
    # the teacher's course is created
    @pytest.mark.skipif(str(7756) not in TESTS, reason='Excluded')
    def test_teacher_access_cc_support_before_course_is_created_7756(self):
        """Access CC help and support before the teacher's course is created.

        Steps:
        Open the recruitment website ( http://cc.openstax.org/ )
        Click "Support" in the header

        Expected Result:
        A new tab opens with the CC Help Center
        """
        self.ps.test_updates['name'] = 'cc1.01.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.006', '7756']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        if self.teacher.driver.get_window_size()['width'] < \
                self.CONDENSED_WIDTH:
            self.teacher.wait.until(
                expect.visibility_of_element_located(
                    (By.XPATH, '//label[@for="mobileNavToggle" and ' +
                     'contains(@class,"fixed")]'))).click()
            self.teacher.sleep(1)
        self.teacher.find(By.XPATH, '//a[contains(text(),"support")]').click()
        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(),"Concept Coach Help Center")]')

        self.ps.test_updates['passed'] = True

    # Case C7757 - 007 - Teacher | Teacher registers to use a CC course
    @pytest.mark.skipif(str(7757) not in TESTS, reason='Excluded')
    def test_teacher_teacher_registers_to_use_a_cc_course_7757(self):
        """Teacher registers to use a Concept Coach course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button

        Expected Result:
        Web form renders
        """
        self.ps.test_updates['name'] = 'cc1.01.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.007', '7757']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        self.ps.test_updates['passed'] = True

    # Case C7758 - 008 - Teacher | Teacher uses a web form to sign up for CC
    @pytest.mark.skipif(str(7758) not in TESTS, reason='Excluded')
    def test_teacher_teacher_uses_a_web_form_to_sign_up_for_cc_7758(self):
        """Teacher uses a web form to sign up for Concept Coach.

        Steps:
        Teacher fills out the form

        Expected Result:
        Preconditions pass.
        User is presented with a confirmation message
        """
        self.ps.test_updates['name'] = 'cc1.01.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.008', '7758']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        self.teacher.find(By.ID, 'first_name').send_keys('first')
        self.teacher.find(By.ID, 'last_name').send_keys('last')
        self.teacher.find(By.ID, 'email').send_keys('*****@*****.**')
        self.teacher.find(By.ID, 'company').send_keys('school')
        menu = self.teacher.find(
            By.XPATH, '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]').click()
        self.teacher.find(
            By.XPATH,
            '//input[@maxlength="255" and @required]').send_keys('25')
        self.teacher.find(By.XPATH, '//input[@type="submit"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')))
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7759 - 009 - Teacher | Receive error messages if required fields on
    # the sign up form are blank
    @pytest.mark.skipif(str(7759) not in TESTS, reason='Excluded')
    def test_teacher_receive_error_messages_if_required_fields_are_7759(self):
        """Receive error messages if required fields on the sign up form are blank.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Submit the form without changing any of the text fields

        Expected Result:
        Receive 'Please fill out this field' error messages in red for
        each blank required field
        """
        self.ps.test_updates['name'] = 'cc1.01.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.009', '7759']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        submit = self.teacher.find(By.XPATH, '//input[@type="submit"]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', submit)
        self.teacher.sleep(0.5)
        submit.click()
        assert('/sign-up' in self.teacher.current_url()), \
            'moved from sign up when submitting with blank required fields'
        self.teacher.find(
            By.XPATH, '//div[contains(text(),"Please fill out this field.")]')

        self.ps.test_updates['passed'] = True

    # Case C7760 - 010 - Teacher | Submit a form to supply required course info
    @pytest.mark.skipif(str(7760) not in TESTS, reason='Excluded')
    def test_teacher_submit_a_form_to_supply_required_course_info_7760(self):
        """Submit a form to supply required course information.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Web form submits
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.010', '7760']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        self.teacher.find(By.ID, 'first_name').send_keys('first')
        self.teacher.find(By.ID, 'last_name').send_keys('last')
        self.teacher.find(By.ID, 'email').send_keys('*****@*****.**')
        self.teacher.find(By.ID, 'company').send_keys('school')
        # choose a book!
        menu = self.teacher.find(
            By.XPATH, '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]').click()
        self.teacher.find(
            By.XPATH,
            '//input[@maxlength="255" and @required]').send_keys('25')
        self.teacher.find(By.XPATH, '//input[@type="submit"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')))
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7761 - 011 - Teacher | Submit co-instructors, classes, names, etc.
    @pytest.mark.skipif(str(7761) not in TESTS, reason='Excluded')
    def test_teacher_submit_coinstructors_classes_names_etc_7761(self):
        """Submit co-instructors, classes, names and other data.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Click on the 'Co-Teaching class with a colleague?' circle button
        Enter the co-instructor's (or co-instructors') information
        Enter text into other fields concerning classe, names, etc.

        Expected Result:
        Input box exists for instructor information, class details and
        other data.
        The user is able to input information.
        """
        self.ps.test_updates['name'] = 'cc1.01.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.011', '7761']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        option = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@class="slide-checkbox"]/label')))
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', option)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        option.click()
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@id="coteachcontact"]/textarea')))
        textarea.send_keys('co teacher info')
        self.ps.test_updates['passed'] = True

    # Case C7762 - 012 - Teacher | Select the textbook to use in the course
    @pytest.mark.skipif(str(7762) not in TESTS, reason='Excluded')
    def test_teacher_select_the_textbook_to_use_in_the_course_7762(self):
        """Select the textbook to use in the course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Select the course textbook from the 'Book' dropdown options

        Expected Result:
        Able to select any Concept Coach textbook
        """
        self.ps.test_updates['name'] = 'cc1.01.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.012', '7762']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        menu = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@id="book-select"]' +
                 '//span[contains(@class,"select2-container--")]')))
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        book = self.teacher.find(
            By.XPATH, '//li[contains(@class,"select2-results__option")]')
        title = book.text
        book.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH, '//span[contains(@title,"' + title + '") and ' +
            'contains(@class,"select2-selection__rendered")]')
        self.ps.test_updates['passed'] = True

    # Case C7763 - 013 - Teacher | Indicate whether the teacher was recruited
    # by OpenStax
    @pytest.mark.skipif(str(7763) not in TESTS, reason='Excluded')
    def test_teacher_indicate_whether_the_teacher_was_recruited_by_7763(self):
        """Indicate if the teacher was or was not recruited by OpenStax.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button ( http://cc.openstax.org/sign-up )
        Enter recruitment information into the 'Anything else we need to know?'
        text box

        Expected Result:
        Able to input recruitment information
        """
        self.ps.test_updates['name'] = 'cc1.01.013' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.013', '7763']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//textarea[@placeholder="Feedback"]')))
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', textarea)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        textarea.send_keys('recuitment info')
        self.ps.test_updates['passed'] = True

    # Case C7764 - 014 - Teacher | Presented a thank you page after registering
    # to use Concept Coach
    @pytest.mark.skipif(str(7764) not in TESTS, reason='Excluded')
    def test_teacher_presented_a_thank_you_page_after_registering_7764(self):
        """Presented a thank you page after registering to use Concept Coach.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.014' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.014', '7764']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        self.teacher.find(By.ID, 'first_name').send_keys('first')
        self.teacher.find(By.ID, 'last_name').send_keys('last')
        self.teacher.find(By.ID, 'email').send_keys('*****@*****.**')
        self.teacher.find(By.ID, 'company').send_keys('school')
        menu = self.teacher.find(
            By.XPATH, '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]').click()
        self.teacher.find(
            By.XPATH,
            '//input[@maxlength="255" and @required]').send_keys('25')
        self.teacher.find(By.XPATH, '//input[@type="submit"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')))
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7765 - 015 - Teacher | Sign up for an OpenStax Accounts username
    @pytest.mark.skipif(str(7765) not in TESTS, reason='Excluded')
    def test_teacher_sign_up_for_an_openstax_accounts_username_7765(self):
        """Sign up for an OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.015' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.015', '7765']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'signup-form')
        self.teacher.find(By.ID, 'first_name').send_keys('first')
        self.teacher.find(By.ID, 'last_name').send_keys('last')
        self.teacher.find(By.ID, 'email').send_keys('*****@*****.**')
        self.teacher.find(By.ID, 'company').send_keys('school')
        menu = self.teacher.find(
            By.XPATH, '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]').click()
        self.teacher.find(
            By.XPATH,
            '//input[@maxlength="255" and @required]').send_keys('25')
        self.teacher.find(By.XPATH, '//input[@type="submit"]').click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')))
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True

    # Case C7770 - 020 - Admin | Add co-instructors to a course
    @pytest.mark.skipif(str(7770) not in TESTS, reason='Excluded')
    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
        self.teacher.login(username=os.getenv('ADMIN_USER'),
                           password=os.getenv('ADMIN_PASSWORD'))
        self.teacher.open_user_menu()
        self.teacher.find(
            By.XPATH,
            '//a[@role="menuitem" and contains(text(),"Admin")]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Course Organization'))).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Courses'))).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Edit'))).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.PARTIAL_LINK_TEXT, 'Teachers'))).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'course_teacher'))).send_keys('teacher0')
        element = self.teacher.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)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//td[contains(text(),"' + teacher_name + '")]')))

        self.ps.test_updates['passed'] = True

    # Case C7771 - 021 - Teacher | Login with an Existing OpenStax Account
    @pytest.mark.skipif(str(7771) not in TESTS, reason='Excluded')
    def test_teacher_login_with_an_existing_openstax_account_7771(self):
        """Log in with an Existing OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on faculty login
        You are redirected to the accounts page.
        Enter a username and password
        click on Login.

        Expected Result:
        Login should be successful. It should take you to the teacher course
        picker/dashboard page.
        """
        self.ps.test_updates['name'] = 'cc1.01.021' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.021', '7771']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        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 C7772 - 022 - Teacher | Access the Concept Coach course
    @pytest.mark.skipif(str(7772) not in TESTS, reason='Excluded')
    def test_teacher_access_the_cc_course_7772(self):
        """Access the Concept Coach course.

        Steps:
        Once you login you will be taken to a course picker page.
        Click on the course you want to check the dashboard

        Expected Result:
        At Concept Coach teacher dashboard
        """
        self.ps.test_updates['name'] = 'cc1.01.022' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.022', '7772']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        assert('cc-dashboard' in self.teacher.current_url()),\
            'Not taken to dashboard: %s' % self.teacher.current_url()

        self.ps.test_updates['passed'] = True

    # Case C7773 - 023 - Admin | Distribute access codes for the course
    @pytest.mark.skipif(str(7773) not in TESTS, reason='Excluded')
    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

    # Case C7774 - 024 - Teacher | Access CC help and support during the course
    @pytest.mark.skipif(str(7774) not in TESTS, reason='Excluded')
    def test_teacher_acccess_cc_help_and_support_during_the_course_7774(self):
        """Access Concept Coach help and support during the course.

        Steps:
        Login as teacher
        Click on the course name
        On dashboard click on the name of the teacher
        It drops down and displays several options.
        Click on Get Help

        Expected Result:
        It should open a new tab which shows the openstax.force.com
        """
        self.ps.test_updates['name'] = 'cc1.01.024' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.024', '7774']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH,
                          '//a[contains(@href,"/cc-dashboard/")]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.PARTIAL_LINK_TEXT, "Get Help").click()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH,
            '//center[contains(text(),"Concept Coach Help Center")]').click()

        self.ps.test_updates['passed'] = True

    # Case C7775 - 025 - Teacher | Access CC help and support after course ends
    @pytest.mark.skipif(str(7775) not in TESTS, reason='Excluded')
    def test_teacher_access_cc_help_and_support_after_course_ends_7775(self):
        """Access Concept Coach help and support after the end of the course.

        Steps:
        Login as teacher
        Click on the course name
        On dashboard click on the name of the teacher
        It drops down and displays several options.
        Click on Get Help

        Expected Result:
        It should open a new tab which shows the CC help center
        """
        self.ps.test_updates['name'] = 'cc1.01.025' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.025', '7775']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.open_user_menu()
        self.teacher.find(By.PARTIAL_LINK_TEXT, "Get Help").click()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH,
            '//center[contains(text(),"Concept Coach Help Center")]').click()

        self.ps.test_updates['passed'] = True
Esempio n. 11
0
class TestRecruitingTeachers(unittest.TestCase):
    """CC1.01 - Recruiting Teachers."""
    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)
        else:
            self.teacher = Teacher(use_env_vars=True)
        self.CONDENSED_WIDTH = 1105

    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.teacher.delete()
        except:
            pass

    # Case C7751 - 001 - Admin | Recruitment and promo website is available
    @pytest.mark.skipif(str(7751) not in TESTS, reason='Excluded')
    def test_admin_recruitment_and_promo_website_is_available_7751(self):
        """Recruitment and promo website is available.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Recruitment website loads and renders
        """
        self.ps.test_updates['name'] = 'cc1.01.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.001', '7751']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        assert('OpenStax Concept Coach' in self.teacher.driver.page_source), \
            'Not on the Concept Coach entry site'

        self.ps.test_updates['passed'] = True

    # Case C7752 - 002 - Teacher | Information about Concept Coach and the
    # pilot are available on the demo site
    @pytest.mark.skipif(str(7752) not in TESTS, reason='Excluded')
    def test_teacher_information_about_cc_is_available_on_demo_site_7752(self):
        """Information about CC and pilot are available on the demo site.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )

        Expected Result:
        Page loads several sections describing Concept Coach
        """
        self.ps.test_updates['name'] = 'cc1.01.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.002', '7752']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(By.ID, 'who-we-are')

        self.ps.test_updates['passed'] = True

    # Case C7753 - 003 - Teacher | Can interact with a Concept Coach wire frame
    # for each subject
    @pytest.mark.skipif(str(7753) not in TESTS, reason='Excluded')
    def test_teacher_can_interact_with_a_cc_wire_frame_for_subjects_7753(self):
        """Can interact with a Concept Coach wire frame for each subject.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/)
        Hover over "demos" in the header
        Click "Interactice Demo"
        CLick on a Concept Coach book title

        Expected Result:
        A new tab or window opens rendering the demo content for the selected
        book
        """
        self.ps.test_updates['name'] = 'cc1.01.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.003', '7753']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH, '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        assert('http://cc.openstax.org/assets/demos/cc-mockup' in
               self.teacher.current_url()), \
            'not at demo book'
        self.ps.test_updates['passed'] = True

    # # NOT DONE
    # Case C7754 - 004 - Teacher | View a Concept Coach demo video
    @pytest.mark.skipif(str(7754) not in TESTS, reason='Excluded')
    def test_teacher_view_a_concept_coach_demo_video_7754(self):
        """View a Concept Coach demo video.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until an embedded video pane is displayed
        Click on the right-pointing arrow to play the video

        Expected Result:
        The video loads and plays
        """
        self.ps.test_updates['name'] = 'cc1.01.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.004', '7754']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # Load demo site
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()

        # Use the physics demo
        demo_link = self.teacher.find(By.CSS_SELECTOR, 'a[href*="physics"]')
        self.teacher.scroll_to(demo_link)
        self.teacher.sleep(1)
        demo_link.click()

        # Switch tab/window to show the physics demo course
        target_window = len(self.teacher.driver.window_handles) - 1
        window_with_book = self.teacher.driver.window_handles[target_window]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(1)

        # Grab the iframe tag for manipulation
        video = self.teacher.wait.until(
            expect.visibility_of_element_located((By.TAG_NAME, 'iframe')))
        self.teacher.scroll_to(video)

        # Retrieve IDs and enable the YouTube javascript API
        self.teacher.driver.switch_to_default_content()
        video_id = video.get_attribute('id')
        content_id = video.get_attribute('src').split('/')[-1]
        print('Video: {0}, Content: {1}'.format(video_id, content_id))
        set_src = video.get_attribute('src') + '?enablejsapi=1'
        self.teacher.driver.execute_script("arguments[0].src = arguments[1];",
                                           video, set_src)
        self.teacher.driver.execute_script(
            "arguments[0].setAttribute('enablejsapi', '1');", video)
        states = {
            '-1': 'Unstarted',
            '0': 'Ended',
            '1': 'Playing',
            '2': 'Paused',
            '3': 'Buffering',
            '5': 'Video cued',
        }

        # Run the API control to play the demo video
        app_script = '''
        var tag = document.createElement("script");
        tag.src = "https://www.youtube.com/iframe_api";
        tag.type = "text/javascript";
        var firstScriptTag = document.getElementsByTagName("script")[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
        window.onYouTubeIframeAPIReady = function() {
            window.player = new YT.Player("''' + video_id + '''", {
                videoId: "''' + content_id + '''",
                events: { "onReady": onPlayerReady }
            });
        }
        function onPlayerReady(event) { event.target.playVideo(); }
        '''
        self.teacher.driver.execute_script(app_script)

        # Wait a bit then check the video status to see if it is playing
        self.teacher.sleep(2.5)
        state = self.teacher.driver.execute_script(
            'return player.getPlayerState();')
        assert((int(state) if state is not None else state) == 1), \
            'Video player is %s, not Playing' % states[state]

        self.ps.test_updates['passed'] = True

    # Case C7755 - 005 - Teacher | Sample exercise questions are seen in
    # the wire frames
    @pytest.mark.skipif(str(7755) not in TESTS, reason='Excluded')
    def test_teacher_sample_exercise_questions_are_in_wire_frames_7755(self):
        """Sample exercise questions are seen in the wire frames.

        Steps:
        Open recruitment website ( http://cc.openstax.org/ )
        Hover over "demos" in the header
        Click "Interactive Demo"
        Click on a Concept Coach book title
        Scroll down until the 'CONCEPT COACH' pane is displayed

        Expected Result:
        Demo exercises are rendered and can be answered along with showing
        feedback
        """
        self.ps.test_updates['name'] = 'cc1.01.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.005', '7755']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        demo_link = self.teacher.find(
            By.XPATH, '//section[@id="interactive-demo"]' +
            '//a[@class="btn" and contains(@href,"cc-mockup-physics")]')
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', demo_link)
        self.teacher.driver.execute_script('window.scrollBy(0, -80);')
        self.teacher.sleep(1)
        demo_link.click()
        window_with_book = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_book)
        self.teacher.page.wait_for_page_load()
        self.teacher.sleep(1)
        self.teacher.find(
            By.XPATH,
            '//span[contains(text(),"JUMP TO CONCEPT COACH")]').click()
        self.teacher.find(By.XPATH,
                          '//div[contains(@data-label,"q1-multiple-choice")]')
        self.teacher.sleep(2)
        answer = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@data-label,"choice-1b-text")]')))
        actions = ActionChains(self.teacher.driver)
        actions.move_to_element(answer)
        actions.click()
        actions.perform()
        self.teacher.find(By.XPATH, "//div[@data-label='State2']").click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 "//div[@data-label='q1-answer-b']//div[@data-label='next']")))
        self.ps.test_updates['passed'] = True

    # Case C7756 - 006 - Teacher | Access Concept Coach help and support before
    # the teacher's course is created
    @pytest.mark.skipif(str(7756) not in TESTS, reason='Excluded')
    def test_teacher_access_cc_support_before_course_is_created_7756(self):
        """Access CC help and support before the teacher's course is created.

        Steps:
        Open the recruitment website ( http://cc.openstax.org/ )
        Click "Support" in the header

        Expected Result:
        A new tab opens with the CC Help Center
        """
        self.ps.test_updates['name'] = 'cc1.01.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.006', '7756']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@id="headerNav"]//a[contains(text(),"support")]').click()
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.page.wait_for_page_load()
        self.teacher.driver.find_element(
            By.XPATH, '//center[text()="OpenStax Concept Coach Support"]')
        self.ps.test_updates['passed'] = True

    '''
    # Case C7757 - 007 - Teacher | Teacher registers to use a CC course
    @pytest.mark.skipif(str(7757) not in TESTS, reason='Excluded')
    def test_teacher_teacher_registers_to_use_a_cc_course_7757(self):
        """Teacher registers to use a Concept Coach course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button

        Expected Result:
        Web form renders
        """
        self.ps.test_updates['name'] = 'cc1.01.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.007',
            '7757'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7758 - 008 - Teacher | Teacher uses a web form to sign up for CC
    @pytest.mark.skipif(str(7758) not in TESTS, reason='Excluded')
    def test_teacher_teacher_uses_a_web_form_to_sign_up_for_cc_7758(self):
        """Teacher uses a web form to sign up for Concept Coach.

        Steps:
        Teacher fills out the form

        Expected Result:
        Preconditions pass.
        User is presented with a confirmation message
        """
        self.ps.test_updates['name'] = 'cc1.01.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.008',
            '7758'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7759 - 009 - Teacher | Receive error messages if required fields on
    # the sign up form are blank
    @pytest.mark.skipif(str(7759) not in TESTS, reason='Excluded')
    def test_teacher_receive_error_messages_if_required_fields_are_7759(self):
        """Receive error messages if required fields on sign up form are blank.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Submit the form without changing any of the text fields

        Expected Result:
        Receive 'Please fill out this field' error messages in red for
        each blank required field
        """
        self.ps.test_updates['name'] = 'cc1.01.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.009',
            '7759'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        submit = self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', submit)
        self.teacher.sleep(0.5)
        submit.click()
        assert('/sign-up' in self.teacher.current_url()), \
            'moved from sign up when submitting with blank required fields'
        self.teacher.find(
            By.XPATH, '//div[contains(text(),"Please fill out this field.")]'
        )

        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7760 - 010 - Teacher | Submit a form to supply required course info
    @pytest.mark.skipif(str(7760) not in TESTS, reason='Excluded')
    def test_teacher_submit_a_form_to_supply_required_course_info_7760(self):
        """Submit a form to supply required course information.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Web form submits
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.010',
            '7760'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        # choose a book!
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7761 - 011 - Teacher | Submit co-instructors, classes, names, etc.
    @pytest.mark.skipif(str(7761) not in TESTS, reason='Excluded')
    def test_teacher_submit_coinstructors_classes_names_etc_7761(self):
        """Submit co-instructors, classes, names and other data.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button
        Click on the 'Co-Teaching class with a colleague?' circle button
        Enter the co-instructor's (or co-instructors') information
        Enter text into other fields concerning classe, names, etc.

        Expected Result:
        Input box exists for instructor information, class details and
        other data.
        The user is able to input information.
        """
        self.ps.test_updates['name'] = 'cc1.01.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.011',
            '7761'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        option = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@class="slide-checkbox"]/label')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', option)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        option.click()
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@id="coteachcontact"]/textarea')
            )
        )
        textarea.send_keys('co teacher info')
        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7762 - 012 - Teacher | Select the textbook to use in the course
    @pytest.mark.skipif(str(7762) not in TESTS, reason='Excluded')
    def test_teacher_select_the_textbook_to_use_in_the_course_7762(self):
        """Select the textbook to use in the course.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Select the course textbook from the 'Book' dropdown options

        Expected Result:
        Able to select any Concept Coach textbook
        """
        self.ps.test_updates['name'] = 'cc1.01.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.012',
            '7762'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        menu = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//span[@id="book-select"]' +
                 '//span[contains(@class,"select2-container--")]')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        book = self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        )
        title = book.text
        book.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//span[contains(@title,"' + title + '") and ' +
            'contains(@class,"select2-selection__rendered")]'
        )
        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7763 - 013 - Teacher | Indicate whether the teacher was recruited
    # by OpenStax
    @pytest.mark.skipif(str(7763) not in TESTS, reason='Excluded')
    def test_teacher_indicate_whether_the_teacher_was_recruited_by_7763(self):
        """Indicate if the teacher was or was not recruited by OpenStax.

        Steps:
        Go to the recruitment and promo website ( http://cc.openstax.org/ )
        Click on the 'sign up now' button ( http://cc.openstax.org/sign-up )
        Enter recruitment information into the 'Anything else we need to know?'
        text box

        Expected Result:
        Able to input recruitment information
        """
        self.ps.test_updates['name'] = 'cc1.01.013' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.013',
            '7763'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        textarea = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//textarea[@placeholder="Feedback"]')
            )
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', textarea)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        textarea.send_keys('recuitment info')
        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7764 - 014 - Teacher | Presented a thank you page after registering
    # to use Concept Coach
    @pytest.mark.skipif(str(7764) not in TESTS, reason='Excluded')
    def test_teacher_presented_a_thank_you_page_after_registering_7764(self):
        """Presented a thank you page after registering to use Concept Coach.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.014' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.014',
            '7764'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True
    '''
    '''
    # Case C7765 - 015 - Teacher | Sign up for an OpenStax Accounts username
    @pytest.mark.skipif(str(7765) not in TESTS, reason='Excluded')
    def test_teacher_sign_up_for_an_openstax_accounts_username_7765(self):
        """Sign up for an OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org )
        Click on the 'sign up now' button
        Fill out the intent to participate form
        Submit the form

        Expected Result:
        Displays a Thank you message panel
        """
        self.ps.test_updates['name'] = 'cc1.01.015' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.015',
            '7765'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('http://cc.openstax.org/')
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//section[@id="video2"]//a[@href="/sign-up"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.ID, 'signup-form'
        )
        self.teacher.find(
            By.ID, 'first_name'
        ).send_keys('first')
        self.teacher.find(
            By.ID, 'last_name'
        ).send_keys('last')
        self.teacher.find(
            By.ID, 'email'
        ).send_keys('*****@*****.**')
        self.teacher.find(
            By.ID, 'company'
        ).send_keys('school')
        menu = self.teacher.find(
            By.XPATH,
            '//span[@id="book-select"]' +
            '//span[contains(@class,"select2-container--")]'
        )
        self.teacher.driver.execute_script(
            'return arguments[0].scrollIntoView();', menu)
        self.teacher.driver.execute_script('window.scrollBy(0, -120);')
        self.teacher.sleep(0.5)
        menu.click()
        self.teacher.sleep(0.5)
        self.teacher.find(
            By.XPATH,
            '//li[contains(@class,"select2-results__option")]'
        ).click()
        self.teacher.find(
            By.XPATH, '//input[@maxlength="255" and @required]'
        ).send_keys('25')
        self.teacher.find(
            By.XPATH, '//input[@type="submit"]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[contains(text(),"Thank you")]')
            )
        )
        assert('/thank-you' in self.teacher.current_url()), \
            'not at thank you page after submitting form'

        self.ps.test_updates['passed'] = True
    '''

    # Case C7770 - 020 - Admin | Add co-instructors to a course
    @pytest.mark.skipif(str(7770) not in TESTS, reason='Excluded')
    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

    # Case C7771 - 021 - Teacher | Login with an Existing OpenStax Account
    @pytest.mark.skipif(str(7771) not in TESTS, reason='Excluded')
    def test_teacher_login_with_an_existing_openstax_account_7771(self):
        """Log in with an Existing OpenStax Accounts username.

        Steps:
        Go to the recruitment website ( http://cc.openstax.org/ )
        Click on faculty login
        You are redirected to the accounts page.
        Enter a username and password
        click on Login.

        Expected Result:
        Login should be successful. It should take you to the teacher course
        picker/dashboard page.
        """
        self.ps.test_updates['name'] = 'cc1.01.021' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.021', '7771']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        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.CSS_SELECTOR, '.primary').click()
        self.teacher.find(By.ID,
                          'login_password').send_keys(self.teacher.password)
        self.teacher.find(By.CSS_SELECTOR, '.primary').click()
        self.teacher.page.wait_for_page_load()
        # check if a password change is required
        if 'reset your password' in self.teacher.driver.page_source.lower():
            try:
                self.teacher.find(By.ID, 'set_password_password') \
                    .send_keys(self.teacher.password)
                self.teacher.find(
                    By.ID, 'set_password_password_confirmation') \
                    .send_keys(self.teacher.password)
                self.teacher.find(By.CSS_SELECTOR, '.primary').click()
                self.teacher.sleep(1)
                self.teacher.find(By.CSS_SELECTOR, '.primary').click()
            except Exception as e:
                raise e
        self.teacher.page.wait_for_page_load()
        source = self.teacher.driver.page_source.lower()
        print('Reached Terms/Privacy')
        while 'terms of use' in source or 'privacy policy' in source:
            self.teacher.accept_contract()
            self.teacher.page.wait_for_page_load()
            source = self.teacher.driver.page_source.lower()
        assert('dashboard' in self.teacher.current_url()),\
            'Not taken to dashboard: %s' % self.teacher.current_url()

        self.ps.test_updates['passed'] = True

    # Case C7772 - 022 - Teacher | Access the Concept Coach course
    @pytest.mark.skipif(str(7772) not in TESTS, reason='Excluded')
    def test_teacher_access_the_cc_course_7772(self):
        """Access the Concept Coach course.

        Steps:
        Once you login you will be taken to a course picker page.
        Click on the course you want to check the dashboard

        Expected Result:
        At Concept Coach teacher dashboard
        """
        self.ps.test_updates['name'] = 'cc1.01.022' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.022', '7772']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.get('https://cc.openstax.org/')
        self.teacher.sleep(2)
        try:
            self.teacher.find(By.CSS_SELECTOR,
                              '#headerNav [href*="tutor"]').click()
        except:
            self.teacher.find_all(By.CSS_SELECTOR,
                                  '.mobile-nav-toggle-label')[1].click()
            self.teacher.sleep(0.5)
            self.teacher.find(By.CSS_SELECTOR,
                              '#sidecarNav [href*="tutor"]').click()
        self.teacher.login()
        courses = self.teacher.find_all(
            By.XPATH, '//*[@class="course-listing-current"]' +
            '//a[p[contains(text(),"Concept Coach")]]')
        if not isinstance(courses, list):
            courses.click()
        elif len(courses) == 1:
            courses[0].click()
        else:
            course_id = randint(0, len(courses))
            print(len(courses), course_id, courses)
            courses[course_id].click()
        self.teacher.page.wait_for_page_load()
        self.teacher.wait.until(
            expect.presence_of_element_located(
                (By.XPATH, '//span[contains(text(),"Class Dashboard")]')))

        self.ps.test_updates['passed'] = True

    '''
    # Case C7773 - 023 - Admin | Distribute access codes for the course
    @pytest.mark.skipif(str(7773) not in TESTS, reason='Excluded')
    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

        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        # Test steps and verification assertions
        admin = None
        if not LOCAL_RUN:
            admin = Admin(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            admin = Admin(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
            )
        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
    '''
    '''
    # Case C7774 - 024 - Teacher | Access CC help and support during the course
    @pytest.mark.skipif(str(7774) not in TESTS, reason='Excluded')
    def test_teacher_acccess_cc_help_and_support_during_the_course_7774(self):
        """Access Concept Coach help and support during the course.

        Steps:
        Login as teacher
        Click on the course name
        On dashboard click on the name of the teacher
        It drops down and displays several options.
        Click on Get Help

        Expected Result:
        It should open a new tab which shows the openstax.force.com
        """
        self.ps.test_updates['name'] = 'cc1.01.024' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.024',
            '7774'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.username = os.getenv('TEACHER_USER_CC')
        self.teacher.login()
        self.teacher.find(
            By.XPATH, '//div[text()="Concept Coach"]/preceding-sibling::a'
        ).click()
        self.teacher.wait.until(
            expect.presence_of_element_located(
                (By.CSS_SELECTOR, 'div.hide-section-legend')
            )
        )
        self.teacher.open_user_menu()
        support = self.teacher.find(
            By.XPATH, '//a[contains(text(),"Get Help")]'
        )
        support_link = support.get_attribute('href')
        Assignment.scroll_to(self.teacher.driver, support)
        support.click()
        handles = len(self.teacher.driver.window_handles)
        if handles <= 1:
            self.teacher.driver.execute_script("window.open('');")
        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        if handles <= 1:
            self.teacher.get(support_link)
            self.teacher.page.wait_for_page_load()
        self.teacher.find(
            By.XPATH, '//center[contains(text(),"Concept Coach Help Center")]'
        ).click()

        self.ps.test_updates['passed'] = True
    '''
    '''
Esempio n. 12
0
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 TestTeacherLoginAndAuthentification(unittest.TestCase):
    """CC1.11 - Teacher Login and Authentification."""
    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)
        else:
            self.teacher = Teacher(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.teacher.delete()
        except:
            pass

    # Case C7688 - 001 - Teacher | Log into Concept Coach
    @pytest.mark.skipif(str(7688) not in TESTS, reason='Excluded')
    def test_teacher_log_into_concept_coach_7688(self):
        """Log into Concept Coach.

        Steps:
        Go to Tutor
        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

        Expected Result:
        User is taken to the class dashboard.
        """
        self.ps.test_updates['name'] = 'cc1.11.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.11', 'cc1.11.001', '7688']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        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.CSS_SELECTOR, '.primary').click()
        self.teacher.find(By.ID,
                          'login_password').send_keys(self.teacher.password)
        self.teacher.find(By.CSS_SELECTOR, '.primary').click()
        self.teacher.page.wait_for_page_load()
        # check if a password change is required
        if 'reset your password' in self.teacher.driver.page_source.lower():
            try:
                self.teacher.find(By.ID, 'set_password_password') \
                    .send_keys(self.teacher.password)
                self.teacher.find(
                    By.ID, 'set_password_password_confirmation') \
                    .send_keys(self.teacher.password)
                self.teacher.find(By.CSS_SELECTOR, '.primary').click()
                self.teacher.sleep(1)
                self.teacher.find(By.CSS_SELECTOR, '.primary').click()
            except Exception as e:
                raise e
        self.teacher.page.wait_for_page_load()
        source = self.teacher.driver.page_source.lower()
        print('Reached Terms/Privacy')
        while 'terms of use' in source or 'privacy policy' in source:
            self.teacher.accept_contract()
            self.teacher.page.wait_for_page_load()
            source = self.teacher.driver.page_source.lower()
        assert('dashboard' in self.teacher.current_url()),\
            'Not taken to dashboard: %s' % self.teacher.current_url()

        self.teacher.driver.find_element(
            By.XPATH,
            '//p[contains(text(),"OpenStax Concept Coach")]').click()
        self.teacher.driver.find_element(By.XPATH,
                                         '//span[text()="Class Dashboard"]')

        self.ps.test_updates['passed'] = True

    # Case C7689 - 002 - Teacher | Logging out returns to the Concept Coach
    # landing page
    @pytest.mark.skipif(str(7689) not in TESTS, reason='Excluded')
    def test_teacher_logging_out_returns_to_concept_coach_landing_p_7689(self):
        """Logging out returns to the Concept Coach landing page.

        Steps:
        Click the user menu containing the user's name
        Click the 'Log Out' button

        Expected Result:
        User is taken to cc.openstax.org
        """
        self.ps.test_updates['name'] = 'cc1.11.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.11', 'cc1.11.002', '7689']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH,
            '//p[contains(text(),"OpenStax Concept Coach")]').click()
        self.teacher.open_user_menu()
        self.teacher.sleep(1)
        self.teacher.find(By.XPATH, "//a//input[@value='Log out']").click()

        assert('cc.openstax.org' in self.teacher.current_url()), \
            'Not viewing the calendar dashboard'

        self.ps.test_updates['passed'] = True

    '''