예제 #1
0
    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
class TestGenerateReports(unittest.TestCase):
    """T1.68 - Generate Reports."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.admin.login()

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

    # Case C8361 - 001 - Admin | Export research data to OwnCloud Research
    @pytest.mark.skipif(str(8361) not in TESTS, reason='Excluded')
    def test_admin_export_research_data_to_own_cloud_research_8361(self):
        """Export research data to OwnCloud Research.

        Steps:
        Open the user menu by clicking on the user's name
        Click on the 'Admin' button
        Click the 'Research Data' button
        Click on the 'Export Data' button

        Expected Result:
        The page is reloaded and a confirmation message is displayed.
        """
        self.ps.test_updates['name'] = 't1.68.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.68', 't1.68.001', '8361']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Admin')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Research Data")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Export Data"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//div[contains(@class,"alert-info")]')

        self.ps.test_updates['passed'] = True
    def test_admin_distribute_access_codes_for_the_course_7773(self):
        """Distribute access codes for the teacher's course.

        Steps:
        CC approves a faculty.
        Login as admin
        Click on user menu
        Click on Admin
        Click on Salesforce tab
        Click on import [Do not check the box]
        This will automatically create a course for the teacher created.
        Email is sent to the email id used when signing up with
            the unique course URL.

        Expected Result:
        Instructors are emailed the unique course url to the address provided
        when they signed up.
        """
        self.ps.test_updates['name'] = 'cc1.01.023' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.01',
            'cc1.01.023',
            '7773'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        admin = Admin(
            use_env_vars=True,
            existing_driver=self.teacher.driver,
            # pasta_user=self.ps,
            # capabilities=self.desired_capabilities
        )
        admin.login()
        admin.open_user_menu()
        admin.find(By.LINK_TEXT, 'Admin').click()
        admin.page.wait_for_page_load()
        admin.find(By.LINK_TEXT, 'Salesforce').click()
        admin.page.wait_for_page_load()
        admin.find(
            By.XPATH, '//input[@vale="Import Courses"]'
        ).click()

        self.ps.test_updates['passed'] = True
    def test_admin_distribute_access_codes_for_the_course_7773(self):
        """Distribute access codes for the teacher's course.

        Steps:
        CC approves a faculty.
        Login as admin
        Click on user menu
        Click on Admin
        Click on Salesforce tab
        Click on import [Do not check the box]
        This will automatically create a course for the teacher created.
        Email is sent to the email id used when signing up with
            the unique course URL.

        Expected Result:
        Instructors are emailed the unique course url to the address provided
        when they signed up.
        """
        self.ps.test_updates['name'] = 'cc1.01.023' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.01', 'cc1.01.023', '7773']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        admin = Admin(
            use_env_vars=True,
            existing_driver=self.teacher.driver,
            # pasta_user=self.ps,
            # capabilities=self.desired_capabilities
        )
        admin.login()
        admin.open_user_menu()
        admin.find(By.LINK_TEXT, 'Admin').click()
        admin.page.wait_for_page_load()
        admin.find(By.LINK_TEXT, 'Salesforce').click()
        admin.page.wait_for_page_load()
        admin.find(By.XPATH, '//input[@vale="Import Courses"]').click()

        self.ps.test_updates['passed'] = True
    def test_admin_import_content_into_tutor_7604(self):
        """Import content into Tutor.

        Steps:
        Select Customer Analyst from the dropdown menu on the name
        Click on Ecosystems in the header
        Click "Download Manifest" for the desired course
        Scroll down and click Import a new Ecosystem button.
        Click "Choose File"
        Select the downloaded file
        In comment section add today's date and your name. Eg: 2016-03-03 Kajal
        Click on the button Import
        Now wait for at most 5 mins.

        Expected Result:
        The message "Ecosystem import job queued" appears at the top
        """
        self.ps.test_updates['name'] = 'cc1.03.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.03',
            'cc1.03.002',
            '7604'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        admin = Admin(
            existing_driver=self.content.driver,
            username=os.getenv('ADMIN_USER'),
            password=os.getenv('ADMIN_PASSWORD'),
            pasta_user=self.ps,
            capabilities=self.desired_capabilities,
        )
        admin.login()
        admin.open_user_menu()
        admin.driver.find_element(
            By.LINK_TEXT, "Content Analyst"
        ).click()
        admin.page.wait_for_page_load()
        admin.driver.find_element(
            By.LINK_TEXT, "Ecosystems"
        ).click()
        # download a manifest to test with
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, "Download Manifest")
            )
        ).click()
        # import a new ecosystem
        admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        admin.driver.find_element(
            By.LINK_TEXT, "Import a new Ecosystem"
        ).click()
        # find a downloaded manifest
        home = os.getenv("HOME")
        files = os.listdir(home + '/Downloads')
        file = ''
        for i in range(len(files)):
            if (files[i][-4:] == '.yml'):
                file = files[i]
                break
            else:
                if i == len(files)-1:
                    print('no .yml file found in downloads')
                    raise Exception
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, "ecosystem_manifest")
            )
        ).send_keys(home + '/Downloads/' + file)
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, "ecosystem_comments")
            )
        ).send_keys(str(datetime.date.today()) + ' automated-admin')
        admin.driver.find_element(
            By.XPATH, "//input[@type='submit']"
        ).click()
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@class,"alert-info")]')
            )
        )
        admin.delete()
        self.ps.test_updates['passed'] = True
예제 #6
0
class TestAdminAndTeacherCourseSetup(unittest.TestCase):
    """CC1.10 - Admin and Teacher Course Setup."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.teacher = Teacher(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.admin = Admin(
            use_env_vars=True,
            existing_driver=self.teacher.driver,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )

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

    # Case C7715 - 001 - Admin | Send course setup data from Sales Force
    @pytest.mark.skipif(str(7715) not in TESTS, reason='Excluded')
    def test_admin_send_course_setup_data_from_sales_force_7715(self):
        """Send course setup data from Sales Force.

        Steps:
        Go to tutor-staging.openstax.org and login as admin
        Click on the user menu
        Select the Admin option
        Click on Salesforce on the header

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.10.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.001',
            '7715'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Salesforce')
            )
        ).click()
        assert('salesforce' in self.admin.current_url()), 'not at salesforce'

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

    # Case C7716 - 002 - System | Course registration codes are emailed to the
    # teacher once the course is set up
    @pytest.mark.skipif(str(7716) not in TESTS, reason='Excluded')
    def test_system_registration_codes_are_emailed_to_teacher_7716(self):
        """Registration codes are emailed to teacher once the course is set up.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.10.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.002',
            '7716'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # Case C7717 - 003 - Teacher | Use a teacher registration code to access
    # their course
    @pytest.mark.skipif(str(7717) not in TESTS, reason='Excluded')
    def test_teacher_use_teacher_registration_code_to_access_course_7717(self):
        """Use a teacher registration code to access their course.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.10.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.003',
            '7717'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # Case C7718 - 004 - Teacher | Create course periods
    @pytest.mark.skipif(str(7718) not in TESTS, reason='Excluded')
    def test_teacher_create_course_periods_7718(self):
        """Create course periods.

        Steps:
        go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click "+ Add section"
        Enter a section name into the section Name text box

        Expected Result:
        New course section created
        """
        self.ps.test_updates['name'] = 'cc1.10.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.004',
            '7718'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@class,"add-period")]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys('test_period')
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Add"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="test_period"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7719 - 005 - Teacher | View student enrollment code for
    # course period
    @pytest.mark.skipif(str(7719) not in TESTS, reason='Excluded')
    def test_teacher_view_student_enrollment_code_for_course_period_7719(self):
        """View the student enrollment code for a course period.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for selected section
        Click 'Get Student Enrollment Code'

        Expected Result:
        Student Enrollment code displayed along with instruction teacher can
        send to students on how to use enrollment code
        """
        self.ps.test_updates['name'] = 'cc1.10.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.005',
            '7719'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//button[contains(@class,"show-enrollment-code")]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="enrollment-code"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7720 - 006 - Teacher | Rename a course period
    @pytest.mark.skipif(str(7720) not in TESTS, reason='Excluded')
    def test_teacher_rename_a_course_period_7720(self):
        """Rename a course period.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for selected section
        Click 'Rename section'
        Enter new section name into the section Name text box
        Click on the 'Rename' button

        Expected Result:
        Section is renamed
        """
        self.ps.test_updates['name'] = 'cc1.10.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.006',
            '7720'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        period_name = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab"]')
            )
        ).text
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(@class,"rename-period")]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys('_EDIT')
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Rename"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + period_name + '_EDIT"]')
            )
        )
        # then set it back to what it was before
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[contains(@class,"rename-period")]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys(Keys.BACK_SPACE * 5)
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Rename"]'
        ).click()

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

    # Case C7721 - 007 - Teacher | Archive an empty period
    @pytest.mark.skipif(str(7721) not in TESTS, reason='Excluded')
    def test_teacher_remove_an_empty_period_7721(self):
        """Remove an empty period.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for selected empty section
        Click 'Archive section'
        Click on the 'Archive' button

        Expected Result:
        Section is archived
        """
        self.ps.test_updates['name'] = 'cc1.10.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.007',
            '7721'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        section_name = 'test_' + str(randint(0, 1000))
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # create an empty section
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@class,"add-period")]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys(section_name)
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Add"]'
        ).click()
        # archive the section just created
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + section_name + '"]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//a[contains(@class,"archive-period")]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@role="tooltip"]//button' +
                 '//span[contains(text(),"Archive")]')
            )
        ).click()
        self.teacher.sleep(2)
        archived = self.teacher.driver.find_elements(
            By.XPATH, '//li//a[@role="tab" and text()="' + section_name + '"]')
        assert(len(archived) == 0), ' not archived'
        self.ps.test_updates['passed'] = True

    # Case C7722 - 008 - Teacher | Archive a non-empty period
    @pytest.mark.skipif(str(7722) not in TESTS, reason='Excluded')
    def test_teacher_archive_a_nonempty_periods_7722(self):
        """Error message displayed if attempting to remove a non-empty period.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for selected non-empty section
        Click 'Archive section'
        Click Archive

        Expected Result:
        Section is archived
        """
        self.ps.test_updates['name'] = 'cc1.10.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.008',
            '7722'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # name of period to archive (first tab)
        period_name = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab"]')
            )
        ).text
        # archive the section
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + period_name + '"]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//a[contains(@class,"archive-period")]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@role="tooltip"]//button' +
                 '//span[contains(text(),"Archive")]')
            )
        ).click()
        self.teacher.sleep(2)
        archived = self.teacher.driver.find_elements(
            By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]')
        assert(len(archived) == 0), ' not archived'
        # add the archived period back
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(@class,"view-archived-periods")]//button')
            )
        ).click()
        periods = self.teacher.driver.find_elements(
            By.XPATH, '//div[@class="modal-content"]//tbody//tr'
        )
        for period in periods:
            try:
                period.find_element(
                    By.XPATH, ".//td[text()='" + period_name + "']")
                period.find_element(
                    By.XPATH,
                    ".//td//span[contains(@class,'restore-period')]//button"
                ).click()
                break
            except NoSuchElementException:
                if period == periods[-1]:
                    raise Exception
        self.teacher.sleep(2)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + period_name + '"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C58354 - 009 - Teacher | Unarchive a section
    @pytest.mark.skipif(str(58354) not in TESTS, reason='Excluded')
    def test_teacher_unarchive_a_section_58354(self):
        """Unarchive a section.

        Steps:
        go to tutor-qa.openstax.org
        log in as a teacher
        click on a Concept Coach book
        click on the user menu
        select course roster
        Click "View Archived Section"
        Click "Unarchive" for the desired section

        Expected Result:
        section is unarchived
        """
        self.ps.test_updates['name'] = 'cc1.10.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.009',
            '58354'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # name of period to archive (first tab)
        period_name = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab"]')
            )
        ).text
        # archive the section
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + period_name + '"]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//a[contains(@class,"archive-period")]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@role="tooltip"]//button' +
                 '//span[contains(text(),"Archive")]')
            )
        ).click()
        self.teacher.sleep(2)
        archived = self.teacher.driver.find_elements(
            By.XPATH, '//li//a[@role="tab" and text()="' + period_name + '"]')
        assert(len(archived) == 0), ' not archived'
        # add the archived period back
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(@class,"view-archived-periods")]//button')
            )
        ).click()
        periods = self.teacher.driver.find_elements(
            By.XPATH, '//div[@class="modal-content"]//tbody//tr'
        )
        for period in periods:
            try:
                period.find_element(
                    By.XPATH, ".//td[text()='" + period_name + "']")
                period.find_element(
                    By.XPATH,
                    ".//td//span[contains(@class,'restore-period')]//button"
                ).click()
                break
            except NoSuchElementException:
                if period == periods[-1]:
                    raise Exception
        self.teacher.sleep(2)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[@role="tab" and text()="' + period_name + '"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7723 - 010 - Teacher | Rename the course
    @pytest.mark.skipif(str(7723) not in TESTS, reason='Excluded')
    def test_teacher_rename_the_course_7723(self):
        """Rename the course.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click 'Rename Course'
        Enter a new Course name into the Course Name text box
        Click on the 'Rename' button

        Expected Result:
        Course is renamed.
        """
        self.ps.test_updates['name'] = 'cc1.10.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.010',
            '7723'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # rename section
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@class="-rename-course-link"]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys("_EDIT")
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Rename"]'
        ).click()
        # check that the name was changed
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="course-settings-title"]' +
                 '//span[contains(text(),"_EDIT")]')
            )
        )
        # change it back
        self.teacher.sleep(1)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//span[@class="-rename-course-link"]//button')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="modal-content"]//input[@type="text"]')
            )
        ).send_keys(Keys.BACK_SPACE * 5)
        self.teacher.driver.find_element(
            By.XPATH,
            '//div[@class="modal-content"]//button/span[text()="Rename"]'
        ).click()

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

    # Case C7724 - 011 - Teacher | Remove other teachers from the course
    @pytest.mark.skipif(str(7724) not in TESTS, reason='Excluded')
    def test_teacher_remove_other_teachers_from_the_course_7724(self):
        """Remove other teachers from the course.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on 'Remove' on the same row as selected teacher
        Click on the 'Remove' button

        Expected Result:
        Instructor is removed from the course
        """
        self.ps.test_updates['name'] = 'cc1.10.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.011',
            '7724'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.driver.get(
            'https://tutor-qa.openstax.org/admin/courses/8/edit')
        self.admin.page.wait_for_page_load()
        teacher_name = 'Trent'
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Teachers")]').click()
        self.admin.driver.find_element(
            By.ID, 'course_teacher').send_keys(teacher_name)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name)
            )
        ).click()
        self.admin.sleep(1)
        self.admin.driver.find_element(
            By.LINK_TEXT, 'Main Dashboard').click()
        self.admin.page.wait_for_page_load()
        self.admin.logout()
        # redo set-up, but make sure to go to course 8
        self.teacher.login()
        self.teacher.driver.get('https://tutor-qa.openstax.org/courses/8')
        self.teacher.open_user_menu()
        self.teacher.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        self.teacher.page.wait_for_page_load()
        # delete teacher
        teachers_list = self.teacher.driver.find_elements(
            By.XPATH, '//div[@class="teachers-table"]//tbody//tr')
        for x in teachers_list:
            temp_first = x.find_element(
                By.XPATH,
                './td[1]'
            ).text
            if temp_first == teacher_name:
                x.find_element(
                    By.XPATH,
                    './/td//span[contains(text(),"Remove")]'
                ).click()
                self.teacher.sleep(1)
                self.teacher.driver.find_element(
                    By.XPATH, '//div[@class="popover-content"]//button'
                ).click()
                break
            if x == teachers_list[-1]:
                print('added teacher was not found, and not deleted')
                raise Exception
        deleted_teacher = self.teacher.driver.find_elements(
            By.XPATH, '//td[contains(text(),"%s")]' % teacher_name)
        assert(len(deleted_teacher) == 0), 'teacher not deleted'

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

    # come back to this because adding teacher through admin first
    # Case C7725 - 012 - Teacher | Remove themself from the course
    @pytest.mark.skipif(str(7725) not in TESTS, reason='Excluded')
    def test_teacher_remove_themself_from_the_course_7725(self):
        """Remove themself from the course.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on 'Remove' on the same row as themselves
        Click on the 'Remove' button

        Expected Result:
        Teacher is removed from course and taken back to dashboard
        """
        self.ps.test_updates['name'] = 'cc1.10.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.012',
            '7725'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.driver.get(
            'https://tutor-qa.openstax.org/admin/courses/8/edit')
        self.admin.page.wait_for_page_load()
        teacher_name = 'Trent'
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Teachers")]').click()
        self.admin.driver.find_element(
            By.ID, 'course_teacher').send_keys(teacher_name)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//li[contains(text(),"%s")]' % teacher_name)
            )
        ).click()
        self.admin.sleep(1)
        self.admin.driver.find_element(
            By.LINK_TEXT, 'Main Dashboard').click()
        self.admin.page.wait_for_page_load()
        self.admin.logout()
        # redo set-up, but make sure to go to course 8
        # login as the teacher just added to the course
        teacher2 = Teacher(
            username='******',
            password=os.getenv('TEACHER_PASSWORD'),
            existing_driver=self.teacher.driver
        )
        teacher2.login()
        teacher2.driver.get('https://tutor-qa.openstax.org/courses/8')
        teacher2.open_user_menu()
        teacher2.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Course Settings and Roster')
            )
        ).click()
        teacher2.page.wait_for_page_load()
        # delete teacher
        teachers_list = teacher2.driver.find_elements(
            By.XPATH, '//div[@class="teachers-table"]//tbody//tr')
        for x in teachers_list:
            temp_first = x.find_element(
                By.XPATH,
                './td[1]'
            ).text
            if temp_first == teacher_name:
                x.find_element(
                    By.XPATH,
                    './/td//span[contains(text(),"Remove")]'
                ).click()
                teacher2.sleep(1)
                teacher2.driver.find_element(
                    By.XPATH, '//div[@class="popover-content"]//button'
                ).click()
                break
            if x == teachers_list[-1]:
                print('added teacher was not found, and not deleted')
                raise Exception
        # after removing self from course taken to dashboard
        # or course if only 1 other course
        assert('/courses/8' not in teacher2.current_url()), \
            'teacher not deleted'
        teacher2.delete()
        self.ps.test_updates['passed'] = True

    # Case C7726 - 013 - Teacher | Transfer a student to another period
    @pytest.mark.skipif(str(7726) not in TESTS, reason='Excluded')
    def test_teacher_transfer_a_student_to_another_period_7726(self):
        """Transfer a student to another period.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for section selected student is currently enrolled in
        Click on 'Change Section' on the row of the selected student
        Click on section to move student to

        Expected Result:
        Student is moved to chosen section
        """
        self.ps.test_updates['name'] = 'cc1.10.013' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.013',
            '7726'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # move student
        first_student = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="period"]//tbody/tr[1]')
            )
        )
        student_name = first_student.find_element(
            By.XPATH, './/td[1]').text
        first_student.find_element(
            By.XPATH,
            './/td[@class="actions"]/a[@aria-describedby="change-period"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="popover-content"]//li[1]')
            )
        ).click()
        # check that student was moved
        self.teacher.sleep(2)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li[@tabindex="1"]//a[@role="tab"]')
            )
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="period"]//tbody/tr' +
                 '//td[text()="' + student_name + '"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7727 - 014 - Teacher | Remove a student from a course
    @pytest.mark.skipif(str(7727) not in TESTS, reason='Excluded')
    def test_teacher_remove_a_student_from_a_course_7727(self):
        """Remove a student from a course.

        Steps:
        Go to Tutor
        Log in as a teacher
        Click on a Concept Coach book
        Click on the user menu
        Select course roster
        Click on tab for section selected student is currently enrolled in
        Click on 'Drop' on the row of the selected student
        Click on the 'Drop' button

        Expected Result:
        Student is dropped from the course
        """
        self.ps.test_updates['name'] = 'cc1.10.014' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.014',
            '7727'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.driver.find_element(
            By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
        ).click()
        self.teacher.page.wait_for_page_load()
        self.teacher.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Course Settings and Roster'
        ).click()
        # drop student
        first_student = self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@class="period"]//tbody/tr[1]')
            )
        )
        student_name = first_student.find_element(
            By.XPATH, './/td[1]').text
        first_student.find_element(
            By.XPATH,
            './/td[@class="actions"]/a[@aria-describedby="drop-student"]'
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[@id="drop-student"]//button')
            )
        ).click()
        # check that student was removed
        self.teacher.sleep(2)
        self.teacher.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(@class,"dropped-students")]//tbody/tr' +
                 '//td[text()="' + student_name + '"]')
            )
        )
        self.ps.test_updates['passed'] = True

    # Case C7728 - 015 - Admin | Impersonate a teacher
    @pytest.mark.skipif(str(7728) not in TESTS, reason='Excluded')
    def test_admin_impersonate_a_teacher_7728(self):
        """Impersonate a teacher.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the admin user account in the username and password text boxes
        Click on the 'Sign in' button
        Click on the user's name in the top right corner to open drop down menu
        Click on the 'Admin' option of the drop down menu
        Click on 'Users' on the bar across the top
        [optional] Enter a teacher name into the search here text box
        Click on the 'Search' button
        Click on the 'Sign in as' button next to chosen teacher

        Expected Result:
        Signs in as chosen chosen teacher.
        Goes to chosen teacher's initial screen after login
        If multiple courses list of textbooks
        If one course straight to dashboard
        """
        self.ps.test_updates['name'] = 'cc1.10.015' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.015',
            '7728'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.admin.driver.find_element(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Users')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(By.ID, 'query').send_keys('teacher01')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Sign in as")]')
            )
        ).click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//span[contains(text(),"Charles Morris")]')
            )
        )

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

    # Case C7729 - 016 - Admin | Change a course ecosystem
    @pytest.mark.skipif(str(7729) not in TESTS, reason='Excluded')
    def test_admin_change_a_course_ecosystem_7729(self):
        """Change a course ecosystem.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the admin user account in the username and password text boxes
        Click on the 'Sign in' button
        Click on the 'Admin' button from the user menu
        Open the drop down menu by clicking 'Course Organization'
        Click the 'Courses' option
        Click the 'Edit' link for the desired course
        Click on the 'Course content' tab
        Select a different option in the 'Ecosystem' drop down menu
        Click the 'Submit' button

        Expected Result:
        Course ecosystem change is put on a queue
        """
        self.ps.test_updates['name'] = 'cc1.10.016' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.016',
            '7729'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Course Organization')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Courses')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Edit')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Course content')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'ecosystem_id')
            )
        ).send_keys('1' + Keys.ENTER)
        # self.admin.wait.until(
        #     expect.visibility_of_element_located(
        #         (By.XPATH, '//select[@id="ecosystem_id"]//option[1]')
        #     )
        # ).click()
        self.admin.driver.find_element(
            By.XPATH, '//div[@id="content"]//input[@type="submit"]'
        ).click()
        self.admin.sleep(1)
        self.admin.driver.find_element(
            By.XPATH, '//div[contains(@class,"alert-info")]'
        )
        self.ps.test_updates['passed'] = True

    # Case C7730 - 017 - Admin | Change multiple course ecosystems in bulk
    @pytest.mark.skipif(str(7730) not in TESTS, reason='Excluded')
    def test_admin_change_multiple_course_ecosystems_in_bulk_7730(self):
        """Change multiple course ecosystems in bulk.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the admin user account in the username and password text boxes
        Click on the 'Sign in' button
        Click on the 'Admin' button from the user menu
        Open the drop down menu by clicking 'Course Organization'
        Click the 'Courses' option
        Check the checkboxes next to selected courses
        Select an option in the 'Select an ecosystem' drop down menu
        Click the 'Set Ecosystem' button

        Expected Result:
        Course ecosystem change is put on a queue
        """
        self.ps.test_updates['name'] = 'cc1.10.017' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.017',
            '7730'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.teacher.driver.find_element(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Course Organization')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, 'Courses')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'courses_select_all')
            )
        ).click()
        # click the checkmarks for two courses
        courses = self.admin.driver.find_elements(
            By.XPATH, '//input[@class="course_id_select"]')
        course_1 = courses[0]
        self.admin.driver.execute_script(
            'return arguments[0].scrollIntoView();', course_1)
        self.admin.driver.execute_script('window.scrollBy(0, -120);')
        course_1.click()
        self.admin.sleep(0.5)
        course_2 = courses[1]
        self.admin.driver.execute_script(
            'return arguments[0].scrollIntoView();', course_2)
        self.admin.driver.execute_script('window.scrollBy(0, -120);')
        course_2.click()
        self.admin.sleep(0.5)
        # scroll to bottom and set bulk ecosystems
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, 'ecosystem_id')
            )
        ).send_keys('1' + Keys.ENTER)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@class,"alert-info")]')
            )
        )

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

    # Case C7731 - 018 - Teacher | Receive a notice when students register
    @pytest.mark.skipif(str(7731) not in TESTS, reason='Excluded')
    def test_teacher_receive_a_notice_when_students_register_7731(self):
        """Receive a notice when students register.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 'cc1.10.018' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.10',
            'cc1.10.018',
            '7731'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

        self.ps.test_updates['passed'] = True
class TestAccountMaintenance(unittest.TestCase):
    """T1.37 - Account Maintenance."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.admin.login()
        self.admin.wait = WebDriverWait(self.admin.driver, 15)
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Admin')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH,
            '//a[contains(text(),"Users")]'
        ).click()

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

    # Case C8247 - 001 - Admin | Search for a username
    @pytest.mark.skipif(str(8247) not in TESTS, reason='Excluded')
    def test_admin_search_for_a_username_8247(self):
        """Search for a username.

        Steps:
        Enter a username into the search here text box
        Click on the 'Search' button

        Expected Result:
        A list of users with the search term in their name,
        or username is displayed.
        """
        self.ps.test_updates['name'] = 't1.37.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.001', '8247']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(
            By.ID, 'query').send_keys('Atticus')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[contains(text(),"Atticus")]')

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

    # Case C8248 - 002 - Admin | Search for a user's name
    @pytest.mark.skipif(str(8248) not in TESTS, reason='Excluded')
    def test_admin_search_for_a_users_name_8248(self):
        """Search for a user's name.

        Steps:
        Click on the user's name in the top right corner to open drop down menu
        Click on the 'Admin' option of the drop down menu
        Click on 'Users' on the bar across the top
        Enter a user's name into the search here text box
        Click on the 'Search' button

        Expected Result:
        A list of users with the search term in their name,
        or username is displayed.
        """
        self.ps.test_updates['name'] = 't1.37.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.002', '8248']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(
            By.ID, 'query').send_keys('student01')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[text()="student01"]')

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

    # Case C8249 - 003 - Admin | Create a new user
    @pytest.mark.skipif(str(8249) not in TESTS, reason='Excluded')
    def test_admin_create_a_user_8249(self):
        """Create a new user.

        Steps:
        Scroll to the bottom of the page
        Click on the 'Create user' button
        Enter account information into:
        -Username, Password, First name, and Last name text boxes
        Click on the 'Save' button

        Expected Result:
        Takes User back to the Users screen. New user is added.
        """
        self.ps.test_updates['name'] = 't1.37.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.003', '8249']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        num = str(randint(0, 999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # look up account to check that the account was made
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[text()="automated_test_user_'+num+'"]')

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

    # Case C8250 - 004 - Admin | Edit a user
    @pytest.mark.skipif(str(8250) not in TESTS, reason='Excluded')
    def test_admin_edit_a_user_8250(self):
        """Edit a user.

        Steps:
        Create a user to edit
        Enter the user's name into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        Enter new account information into the First name text box
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's information is updated
        """
        self.ps.test_updates['name'] = 't1.37.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.004', '8250']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(1000, 1999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('_EDITED')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[contains(text(),"first_name_' + num + '_EDITED")]')

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

    # Case C8251 - 005 - Admin | Assign elevated permissions
    @pytest.mark.skipif(str(8251) not in TESTS, reason='Excluded')
    def test_admin_assign_elevated_permissions_8251(self):
        """Assign elevated permissions.

        Steps:
        Create a user to edit
        Enter the user's username into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        If check box for chosen permission is not checked, click on check box.
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's permissions are modified.
        """
        self.ps.test_updates['name'] = 't1.37.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.005', '8251']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(2000, 2999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'Yes'), \
            'permission not elevated ' + element.get_attribute('innerHTML')

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

    # Case C8252 - 006 - Admin | Remove elevated permissions
    @pytest.mark.skipif(str(8252) not in TESTS, reason='Excluded')
    def test_admin_remove_elevated_permissions_8252(self):
        """Remove elevated permissions.

        Steps:
        Create a user to edit
        Enter the user's name into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        If check box for chosen permission is checked, click to uncheck it.
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's permissions are modified.
        """
        self.ps.test_updates['name'] = 't1.37.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.006', '8252']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(3000, 3999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_'+num)
        self.admin.driver.find_element(
            By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'Yes'), \
            'permission not elevated ' + element.get_attribute('innerHTML')
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'query'))
        ).send_keys('automated_test_user_'+num)
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'No'), \
            'permission not elevated ' + element.get_attribute('innerHTML')

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

    # Case C8253 - 007 - Admin | Impersonate a user
    @pytest.mark.skipif(str(8253) not in TESTS, reason='Excluded')
    def test_admin_impersonate_a_user_8253(self):
        """Impersonate a user.

        Steps:
        Click on the 'Sign in as' button next to a user

        Expected Result:
        Signs in as chosen chosen user.
        Goes to chosen users initial screen after login
        (different depending on the user)
        """
        self.ps.test_updates['name'] = 't1.37.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.007', '8253']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(By.ID, 'query').send_keys('student01')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Search"]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Sign in as")]')
            )
        ).click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//span[contains(text(),"Atticus Finch")]')
            )
        )

        self.ps.test_updates['passed'] = True
예제 #8
0
class TestContractControls(unittest.TestCase):
    """T1.35 - Contract Controls."""
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.admin = Admin(use_env_vars=True,
                               pasta_user=self.ps,
                               capabilities=self.desired_capabilities)
        else:
            self.admin = Admin(use_env_vars=True, )
        self.admin.login()
        # make sure there are no new terms to accept
        try:
            self.admin.driver.find_element(By.ID, 'i_agree').click()
        except NoSuchElementException:
            pass
        try:
            self.admin.driver.find_element(By.ID, 'agreement_submit').click()
        except NoSuchElementException:
            pass
        # go to admin console
        self.wait = WebDriverWait(self.admin.driver, 15)
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.LINK_TEXT, 'Admin'))).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Legal")]').click()

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

    # Case C8228 - 001 - Admin | Add a new contract
    @pytest.mark.skipif(str(8228) not in TESTS, reason='Excluded')
    def test_admin_add_a_new_contract_8228(self):
        """Add a new contract.

        Steps:
        Click on the 'Terms' option
        Click on the "New Contract" Link
        Enter information into the Name, Title, and Content text boxes
        Click on the 'Create contract' button

        Expected Result:
        Contract is created as a draft.
        User is shown the contract they just made,
        and has options on what to do with it next
        """
        self.ps.test_updates['name'] = 't1.35.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.001', '8228']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click(
            )
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]'))).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_001')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_001')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_001')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//h1[contains(text(),"Details")]').click()

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

    '''
    # Case C8229 - 002 - Admin | Cancel adding a new contract
    @pytest.mark.skipif(str(8229) not in TESTS, reason='Excluded')
    def test_admin_cancel_adding_a_new_contract_8229(self):
        """Cancel adding a new contract.

        Steps:
        Click on the 'Terms' option
        Click on the "New Contract" Link
        Enter information into the Name, Title, and Content text boxes
        Click on the 'Create contract' button
        Click on the Delete link

        Expected Result:
        Contract is deleted. User is taken back to the Contracts page.
        """
        self.ps.test_updates['name'] = 't1.35.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.002', '8229']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_002')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_002')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_002')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="Delete"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH, '//div[contains(@class,"alert-info")]')
        contracts = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_002")]')
        assert(len(contracts) == 0), 'contract not cancled'

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

    # Case C8230 - 003 - Admin | Publish a draft contract
    @pytest.mark.skipif(str(8230) not in TESTS, reason='Excluded')
    def test_admin_publish_a_draft_contract_8230(self):
        """Publish a draft contract.

        Steps:
        Click on the 'Terms' option
        Create a draft contract and return to contract list
        Click on the draft contract
        Click on the Publish link
        Click ok

        Expected Result:
        Draft contract is published
        """
        self.ps.test_updates['name'] = 't1.35.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.003', '8230']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click(
            )
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]'))).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_003')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_003')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_003')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_003")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Publish")]').click()
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(
                    expect.alert_is_present(),
                    'Timed out waiting for alert.'
                )
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

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

    # Case C8231 - 004 - Admin | Delete a draft contract
    @pytest.mark.skipif(str(8231) not in TESTS, reason='Excluded')
    def test_admin_delete_a_draft_contract_8231(self):
        """Delete a draft contract.

        Steps:
        Click on the 'Terms' option
        Create a draft contract and return to the contract list
        Click on the draft contract
        Click on Delete next to chosen draft contract

        Expected Result:
        Draft contract is deleted
        """
        self.ps.test_updates['name'] = 't1.35.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.004', '8231']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        contracts_original = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_004")]')

        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click(
            )
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]'))).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_004')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_004')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_004')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_004")]').click()
        self.admin.page.wait_for_page_load()
        self.admin.sleep(2)
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Delete")]').click()
        self.admin.sleep(2)
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(
                    expect.alert_is_present(),
                    'Timed out waiting for alert.'
                )
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')
        self.admin.page.wait_for_page_load()
        contracts = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_004")]')
        self.admin.page.wait_for_page_load()
        assert(len(contracts) == len(contracts_original)), \
            'contract not deleted'

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

    # Case C8232 - 005 - Admin | View a current contract
    @pytest.mark.skipif(str(8232) not in TESTS, reason='Excluded')
    def test_admin_view_a_current_contract_8232(self):
        """View a current contract.

        Steps:
        Click on the 'Terms' option
        Create a contract and then return to contract list
        Click on chosen contract

        Expected Result:
        Displays the information of chosen contract.
        """
        self.ps.test_updates['name'] = 't1.35.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.005', '8232']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click(
            )
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]'))).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_005')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_005')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_005')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]'))).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_005")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//h2[contains(text(),"test_contract_title_005")]')

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

    # Case C8233 - 006 - Admin | Add a new version of a current contract
    @pytest.mark.skipif(str(8233) not in TESTS, reason='Excluded')
    def test_admin_add_a_new_version_of_a_current_contract_8233(self):
        """Add a new version of a current contract.

        Steps:
        Click on the 'Terms' option
        Click on New version next to chosen contract
        Update information in the Name, Title, and Content text boxes.
        Click on the 'Create Contract' button

        Expected Result:
        New version of contract is saved as a draft.
        """
        self.ps.test_updates['name'] = 't1.35.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.006', '8233']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="New Version"]'))).click()
        self.admin.driver.find_element(By.ID,
                                       'contract_name').send_keys('NEW_006')
        self.admin.driver.find_element(By.ID,
                                       'contract_title').send_keys('NEW_006')
        self.admin.driver.find_element(By.ID,
                                       'contract_content').send_keys('NEW_006')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//h2[contains(text(),"NEW_006")]')

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

    # Case C8234 - 007 - Admin | View a contract's signatories
    @pytest.mark.skipif(str(8234) not in TESTS, reason='Excluded')
    def test_admin_view_a_contracts_signatures_8234(self):
        """View a contract's signatories.

        Steps:
        Click on the 'Terms' option
        Click on Signatures next to chosen draft contract

        Expected Result:
        Displays list of signatures for the chosen contract.
        """
        self.ps.test_updates['name'] = 't1.35.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.007', '8234']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        wait = WebDriverWait(self.admin.driver, 45)
        self.admin.driver.find_element(By.XPATH,
                                       '//a[text()="Signatures"]').click()
        wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//div[contains(@class,"signature_index")]')))

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

    # Case C8235 - 008 - Admin | Terminate a signatory's contract
    @pytest.mark.skipif(str(8235) not in TESTS, reason='Excluded')
    def test_admin_terminate_a_signnatorys_contract_8235(self):
        """Terminate a signatory's contract.

        Steps:
        Click on the 'Terms' option
        Click on Signatures next to chosen draft contract
        Click on Terminate next to chosen user
        Click on the 'ok' button

        Expected Result:
        Selected user's signing of contract is terminated.
        """
        self.ps.test_updates['name'] = 't1.35.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.008', '8235']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]'))).click()
        self.admin.driver.find_element(By.XPATH,
                                       '//a[text()="Signatures"]').click()
        # is it okay to just terminate some random person's signature
        wait = WebDriverWait(self.admin.driver, 45)
        wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//td//a[contains(text(),"Terminate")]'))).click()
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(expect.alert_is_present(),
                      'Timed out waiting for PA creation ' +
                      'confirmation popup to appear.')
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

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

    # Case C8236 - 009 - Admin | Add a targeted contract
    @pytest.mark.skipif(str(8236) not in TESTS, reason='Excluded')
    def test_admin_add_a_targeted_contract_8236(self):
        """Add a targeted contract.

        Steps:
        Click on the 'Targeted Contracts' option
        Click on the 'Add Target Contract' button
        Click the 'Submit' button

        Expected Result:
        User taken back to Targeted contracts page.
        New Targeted Contract is added
        """
        self.ps.test_updates['name'] = 't1.35.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.009', '8236']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH,
                 '//a[contains(text(),"Targeted Contracts")]'))).click()
        orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Add Targeted Contract"]').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Submit"]').click()
        end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        assert(len(orig_contracts) == len(end_contracts)-1), \
            'targeted contract not added'

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

    # Case C8237 - 010 - Admin | Delete a targeted contract
    @pytest.mark.skipif(str(8237) not in TESTS, reason='Excluded')
    def test_admin_delete_a_targeted_contract_8237(self):
        """Delete a targeted contract.

        Steps:
        Click on the user's name in the top right corner to open drop down menu
        Click on the 'Admin' option of the drop down menu
        Click on 'Legal' on the bar across the top to open drop down menu
        Click on the 'Targeted Contracts' option
        Create a targeted contract and return to the list of targed contracts
        Click on delete next to chosen contract
        Click on the 'ok' button

        Expected Result:
        Targeted contract is deleted
        """
        self.ps.test_updates['name'] = 't1.35.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.010', '8237']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH,
                 '//a[contains(text(),"Targeted Contracts")]'))).click()
        orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        # create contract
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Add Targeted Contract"]').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Submit"]').click()
        # delete contract
        deletes = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"delete")]')
        deletes[-1].click()
        try:
            WebDriverWait(self.admin.driver,
                          3).until(expect.alert_is_present(),
                                   'Timed out waiting for alert.')
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

        end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        assert(len(orig_contracts) == len(end_contracts)), \
            'targeted contract not added'

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

    '''
class 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 TestOpenStaxMetrics(unittest.TestCase):
    """CC1.15 - OpenStax Metrics."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )

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

    # Case C7608 - 001 - Admin | View a report of enrolled students by course
    @pytest.mark.skipif(str(7608) not in TESTS, reason='Excluded')
    def test_admin_view_a_report_of_enrolled_students_by_course_7608(self):
        """View a report of enrolled students by course.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the admin user account in the username and password text boxes
        Click on the 'Sign in' button
        Click on the 'Admin' button from the user menu
        Open the drop down menu by clicking 'Course Organization'
        Click the 'Courses' option
        Click the 'List Students' button for the chosen course

        Expected Result:
        List of students for chosen course is displayed
        """
        self.ps.test_updates['name'] = 'cc1.15.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.15',
            'cc1.15.001',
            '7608'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.admin.find(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.find(
            By.LINK_TEXT, 'Course Organization'
        ).click()
        self.admin.find(
            By.LINK_TEXT, 'Courses'
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.find(
            By.LINK_TEXT, 'List Students'
        ).click()
        # assert thaken to correct page
        self.admin.find(
            By.XPATH, '//h1[contains(text(),"Students for course")]'
        )
        assert('student' in self.admin.current_url())
        self.ps.test_updates['passed'] = True
class TestGuideMonitorSupportAndTrainUsers(unittest.TestCase):
    """T2.18 - Guide, Monitor, Support, and Train Users."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.teacher = Teacher(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
            self.student = Student(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
            self.admin = Admin(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.teacher = Teacher(
                use_env_vars=True
            )
            self.student = Student(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
            )
            self.admin = Admin(
                use_env_vars=True,
                existing_driver=self.teacher.driver,
            )

    def tearDown(self):
        """Test destructor."""
        if not LOCAL_RUN:
            self.ps.update_job(
                job_id=str(self.teacher.driver.session_id),
                **self.ps.test_updates
            )

        try:
            self.student.driver = None
            self.admin.driver = None
            self.teacher.delete()
        except:
            pass

    # C14752 - 001 - User | In-app Notification of downtime
    @pytest.mark.skipif(str(14752) not in TESTS, reason='Excluded')
    def test_user_inapp_notification_of_downtime_14752(self):
        """In-app Notification of downtime.

        Steps:

        Go to Tutor
        Log in as admin
        Click "Admin" from the user menu
        Click "System Setting"
        Click "Notifications"
        Enter a new notification into the text box
        Click "Add"
        Log out of admin
        Log in as teacher01

        Expected Result:
        An orange header with the notification pops up when you sign in
        """
        self.ps.test_updates['name'] = 't2.18.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.001', '14752']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        # create notification
        self.admin.login()
        self.admin.open_user_menu()
        self.admin.find(By.LINK_TEXT, 'Admin').click()
        self.admin.find(By.XPATH, '//a[text()="System Setting"]').click()
        self.admin.find(By.XPATH, '//a[text()="Notifications"]').click()
        self.admin.find(By.ID, 'message') \
            .send_keys("test_notification")
        self.admin.find(By.XPATH, '//input[@value="Add"]').click()
        self.admin.find(By.XPATH, '//a[text()="admin "]').click()
        self.admin.find(By.XPATH, '//a[text()="Sign out!"]').click()

        # check that the notification appears
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//div[contains(@class,"notifications-bar")]' +
                '//span[text()="test_notification"]'
            ))
        )
        self.teacher.find(
            By.XPATH,
            '//div[contains(@class,"notifications-bar")]' +
            '//span[text()="test_notification"]'
        )
        self.teacher.logout()

        # remove notification
        self.admin.login()
        self.admin.open_user_menu()
        self.admin.find(By.LINK_TEXT, 'Admin').click()
        self.admin.find(By.XPATH, '//a[text()="System Setting"]').click()
        self.admin.find(By.XPATH, '//a[text()="Notifications"]').click()
        self.admin.find(By.XPATH, '//a[text()="Remove"]').click()
        self.admin.driver.switch_to_alert().accept()

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

    # C14751 - 002 - Teacher | Directed to a "No Courses" page when not in any
    # courses yet
    @pytest.mark.skipif(str(14751) not in TESTS, reason='Excluded')
    def test_teacher_directed_to_a_no_courses_page_when_not_in_any_14751(self):
        """Directed to a "No Courses" page when not in any courses yet.

        Steps:
        Go to Tutor
        Sign in as a teacher without a course

        Expected Result:
        The message "We cannot find an OpenStax course associated with your
        account" displays with help links below.
        """
        self.ps.test_updates['name'] = 't2.18.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.002', '14751']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login(
            username='******',
            password=os.getenv('CONTENT_PASSWORD')
        )
        self.teacher.page.wait_for_page_load()

        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//p[contains(text(),"cannot find an ' +
                'OpenStax course associated")]'
            ))
        )

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

    # C58279 - 003 - Teacher | View "Getting Started with Tutor" Guide
    @pytest.mark.skipif(str(58279) not in TESTS, reason='Excluded')
    def test_teacher_view_getting_started_with_tutor_guide_58279(self):
        """View "Getting Started with Tutor" Guide.

        Steps:
        Click "Tutor Instructors. Get help"

        Expected Result:
        Tutor Help Center opens in another tab with the Getting Started guide
        """
        self.ps.test_updates['name'] = 't2.18.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.003', '58279']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('getting started')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        raise NotImplementedError(inspect.currentframe().f_code.co_name)
        self.teacher.find(By.XPATH, '//h1[contains(text(),"Getting Started")]')
        assert('articles' in self.teacher.current_url()), 'not at article'

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

    # C58280 - 004 - Teacher | Access Tutor Help Center after registering for
    # a course
    @pytest.mark.skipif(str(58280) not in TESTS, reason='Excluded')
    def test_teacher_access_tutor_help_center_after_registering_58280(self):
        """Access Tutor Help Center after registering for a course.

        Steps:
        Go to Tutor
        Sign in as teacher01
        Click on a Tutor course if the user is in more than one
        Click "Get Help" from the user menu in the upper right corner of the
            screen

        Expected Result:
        The user is presented with the Tutor Help Center
        """
        self.ps.test_updates['name'] = 't2.18.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.004', '58280']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(
            By.XPATH,
            '//center[contains(text(),"Tutor Support")]'
        )

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

    # C58284 - 005 - User | Submit a question
    @pytest.mark.skipif(str(58284) not in TESTS, reason='Excluded')
    def test_user_submit_a_question_58284(self):
        """Submit a question.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter

        Expected Result:
        The user is presented with search results
        """
        self.ps.test_updates['name'] = 't2.18.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.005', '58284']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.ID, 'results')
        self.teacher.find(By.CSS_SELECTOR, 'div.article')

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

    # 58352 - 006 - User | View "Contact Us" button after submitting a
    # question
    @pytest.mark.skipif(str(58352) not in TESTS, reason='Excluded')
    def test_user_view_contact_us_button_after_submitting_question_58352(self):
        """View "Contact Us" button after submitting a question.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Scroll to the bottom of the screen

        Expected Result:
        "Contact Us" button exists
        """
        self.ps.test_updates['name'] = 't2.18.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.006', '58352']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.XPATH, '//a[contains(text(),"Email Us")]')

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

    # C58288 - 007 - User | View an article after submitting a question
    @pytest.mark.skipif(str(58288) not in TESTS, reason='Excluded')
    def test_user_view_an_article_after_submitting_a_question_58288(self):
        """View an article after submitting a question.

        Steps:

        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result

        Expected Result:
        The user is presented with an article containing answer to the question
        """
        self.ps.test_updates['name'] = 't2.18.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.007', '58288']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, 'div.article a').click()
        self.teacher.find(By.ID, 'articleContainer')
        assert('articles' in self.teacher.current_url()), 'not at article'

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

    # C58313 - 008 - User | Indicate that the article was helpful
    @pytest.mark.skipif(str(58313) not in TESTS, reason='Excluded')
    def test_user_indicate_that_the_article_was_helpful_58313(self):
        """Indicate that the article was helpful.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "Yes"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed
        """
        self.ps.test_updates['name'] = 't2.18.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.008', '58313']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'

        self.teacher.find(By.CSS_SELECTOR, '#feedback [value="Yes"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//div[contains(text(),"Thanks for your feedback!")]'
            ))
        )

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

    # C58314 - 009 - User | Negative feedback renders a feedback popup box
    @pytest.mark.skipif(str(58314) not in TESTS, reason='Excluded')
    def test_user_negative_feedback_renders_feedback_popup_box_58314(self):
        """Negative feedback renders a feedback popup box.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"

        Expected Result:
        The user is presented with a popup box that allows them to input
        feedback
        """
        self.ps.test_updates['name'] = 't2.18.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.009', '58314']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'

        self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.ID,
                'feedbackDialog'
            ))
        )

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

    # C58315 - 010 - User | Submit feedback for an article
    @pytest.mark.skipif(str(58315) not in TESTS, reason='Excluded')
    def test_user_submit_feedback_for_an_article_58315(self):
        """Submit feedback for an article.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed in the box
        """
        self.ps.test_updates['name'] = 't2.18.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.010', '58315']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'

        self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.ID,
                'feedbackDialog'
            ))
        )
        self.teacher.find(By.ID, 'feedbackTextArea') \
            .send_keys('qa automated test feedback')
        self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//p[text()="Thanks for your feedback!"]'
            ))
        )

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

    # C58322 - 011 - User | Close window after submitting feedback for an
    # article
    @pytest.mark.skipif(str(58322) not in TESTS, reason='Excluded')
    def test_user_close_window_after_submitting_feedback_for_58322(self):
        """Close window after submitting feedback for an article.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"
        Click "Close window"

        Expected Result:
        The popup box closes and the message "Thanks for your feedback"
        displays beneath "Feedback"
        """
        self.ps.test_updates['name'] = 't2.18.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.011', '58322']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'
        self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.ID,
                'feedbackDialog'
            ))
        )
        self.teacher.find(By.ID, 'feedbackTextArea') \
            .send_keys('qa automated test feedback')
        self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//a[text()="close window"]'
            ))
        ).click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//div[text()="Thanks for your feedback!"]'
            ))
        )

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

    # C58316 - 012 - User | Cancel feedback
    @pytest.mark.skipif(str(58316) not in TESTS, reason='Excluded')
    def test_user_cancel_feedback_before_making_changes_58316(self):
        """Cancel feedback.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        [optional] Enter feedback into the text box
        Click "Cancel"

        Expected Result:
        The popup box closes
        """
        self.ps.test_updates['name'] = 't2.18.012' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.012', '58316']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'

        self.teacher.find(By.CSS_SELECTOR, '#feedback [value="No"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.ID,
                'feedbackDialog'
            ))
        )
        self.teacher.find(By.CSS_SELECTOR, '[value="Cancel"]').click()
        with self.assertRaises(ElementNotVisibleException):
            self.teacher.find(By.ID, 'feedbackDialog').click()

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

    # C58318 - 013 - User | View related articles
    @pytest.mark.skipif(str(58318) not in TESTS, reason='Excluded')
    def test_user_view_related_articles_58318(self):
        """View related articles.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Related Articles"
        Click on one of the articles (if any)

        Expected Result:
        The user is presented with the related article
        """
        self.ps.test_updates['name'] = 't2.18.013' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.013', '58318']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(By.CSS_SELECTOR, '.article a').click()
        assert('articles' in self.teacher.current_url()), 'not at the article'

        self.teacher.find(By.XPATH, '//h2[text()="Related Articles"]')

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

    # C58319 - 014 - User | Submit a question to Customer Support
    @pytest.mark.skipif(str(58319) not in TESTS, reason='Excluded')
    def test_user_submit_a_question_to_customer_support_58319(self):
        """Submit a question to Customer Support.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        CLick "Search" or press enter
        Click on a search result
        Scroll to the bottom of the page
        CLick "Contact Us"
        Fill out the required fields
        Enter "Submit"

        Expected Result:
        The message "Thank you for your message! We'll be back to you within
        one business day" is displayed
        """
        self.ps.test_updates['name'] = 't2.18.014' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.014', '58319']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.find(By.XPATH, '//p[@data-is-beta="true"]').click()
        self.teacher.open_user_menu()
        self.teacher.find(By.LINK_TEXT, 'Get Help').click()
        self.teacher.sleep(1)

        window_with_help = self.teacher.driver.window_handles[1]
        self.teacher.driver.switch_to_window(window_with_help)
        self.teacher.find(By.ID, 'searchAskInput') \
            .send_keys('question')
        self.teacher.find(By.ID, 'searchAskButton').click()
        self.teacher.page.wait_for_page_load()
        contact = self.teacher.find(
            By.XPATH,
            '//a[contains(text(),"Email Us")]'
        )
        Assignment.scroll_to(self.teacher.driver, contact)
        contact.click()
        self.teacher.page.wait_for_page_load()

        self.teacher.find(
            By.XPATH, '//input[contains(@name,"contactUsForm:firstName")]'
        ).send_keys('qa_test_first_name')
        self.teacher.find(
            By.XPATH, '//input[contains(@name,"contactUsForm:lastName")]'
        ).send_keys('qa_test_last_name')
        self.teacher.find(
            By.XPATH, '//input[contains(@name,"contactUsForm:email")]'
        ).send_keys('*****@*****.**')
        self.teacher.find(By.CSS_SELECTOR, '[value="Submit"]').click()
        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.XPATH,
                '//p[contains(text(),"Thank you for your message!")]'
            ))
        )

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

    # C14755 - 015 - Teacher | View guided tutorials of Tutor
    @pytest.mark.skipif(str(14755) not in TESTS, reason='Excluded')
    def test_teacher_view_guided_tutorials_of_tutor_14755(self):
        """View guided tutorials of Tutor.

        Steps:

        Expected Result:
        """
        self.ps.test_updates['name'] = 't2.18.015' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.015', '14755']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C14750 - 016 - Student | Directed to a "No Courses" page when not in any
    # courses yet
    @pytest.mark.skipif(str(14750) not in TESTS, reason='Excluded')
    def test_student_directed_to_a_no_courses_page_when_not_in_any_14750(self):
        """Directed to a "No Courses" page when not in any courses yet.

        Steps:
        Go to Tutor
        Log in as qa_student_37003

        Expected Result:
        The message "We cannot find an OpenStax course associated with your
        account" displays with help links
        """
        self.ps.test_updates['name'] = 't2.18.016' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.016', '14750']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login(
            username='******',
            password=os.getenv('CONTENT_PASSWORD')
        )
        self.student.page.wait_for_page_load()

        self.teacher.wait.until(
            expect.visibility_of_element_located((
                By.CSS_SELECTOR,
                '.panel-body .lead:first-of-type'
            ))
        )

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

    # C58336 - 017 - Student | View "Getting Started with Tutor" Guide
    @pytest.mark.skipif(str(58336) not in TESTS, reason='Excluded')
    def test_student_view_getting_started_with_tutor_guide_58336(self):
        """View "Getting Started with Tutor" Guide.

        Steps:
        Click "Tutor Students. Get help"

        Expected Result:
        Tutor Help Center opens in another tab with the Getting Started guide
        """
        self.ps.test_updates['name'] = 't2.18.017' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.017', '58336']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58337 - 018 - Student | Access Tutor Help Center after registering for a
    # course
    @pytest.mark.skipif(str(58337) not in TESTS, reason='Excluded')
    def test_student_access_tutor_help_center_after_registering_fo_58337(self):
        """Access Tutor Help Center after registering for a course.

        Steps:
        Go to Tutor
        Sign in as student01
        Click on a Tutor course if the user is in more than one
        Click "Get Help" from the user menu in the upper right corner of the
            screen

        Expected Result:
        The user is presented with the Tutor Help Center
        """
        self.ps.test_updates['name'] = 't2.18.018' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.018', '58337']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.login(
            username='******',
            password=os.getenv('CONTENT_PASSWORD')
        )
        self.student.page.wait_for_page_load()

        self.student.find(By.XPATH, '//a[p[@data-is-beta="true"]]').click()
        self.student.open_user_menu()
        self.student.find(By.LINK_TEXT, 'Get Help').click()
        self.student.sleep(0.5)

        window_with_help = self.student.driver.window_handles[1]
        self.student.driver.switch_to_window(window_with_help)
        self.student.page.wait_for_page_load()

        self.student.find(
            By.XPATH,
            '//center[contains(text(),"Tutor Support")]'
        )

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

    '''
    # C58338 - 019 - Student | Submit a question
    @pytest.mark.skipif(str(58338) not in TESTS, reason='Excluded')
    def test_student_submit_a_question_58338(self):
        """Submit a question.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter

        Expected Result:
        The user is presented with search results
        """
        self.ps.test_updates['name'] = 't2.18.019' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.019', '58338']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58353 - 020 - Student | View "Contact Us" button after submitting a
    # question
    @pytest.mark.skipif(str(58353) not in TESTS, reason='Excluded')
    def test_student_view_contact_us_button_after_submitting_quest_58353(self):
        """View "Contact Us" button after submitting a question.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Scroll to the bottom of the page

        Expected Result:
        "Contact Us" button exists
        """
        self.ps.test_updates['name'] = 't2.18.020' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.020', '58353']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58339 - 021 - Student | View an article after submitting a question
    @pytest.mark.skipif(str(58339) not in TESTS, reason='Excluded')
    def test_student_view_an_article_after_submitting_a_question_58339(self):
        """View an article after submitting a question.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result

        Expected Result:
        The user is presented with an article containing answer to the question
        """
        self.ps.test_updates['name'] = 't2.18.021' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.021', '58339']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58340 - 022 - Student | Indicate that the article was helpful
    @pytest.mark.skipif(str(58340) not in TESTS, reason='Excluded')
    def test_student_indicate_that_the_article_was_helpful_58340(self):
        """Indicate that the article was helpful.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "Yes"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed
        """
        self.ps.test_updates['name'] = 't2.18.022' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.022', '58340']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58341 - 023 - Student | Negative feedback renders a feedback popup box
    @pytest.mark.skipif(str(58341) not in TESTS, reason='Excluded')
    def test_student_negative_feedback_renders_feedback_popup_box_58341(self):
        """Negative feedback renders a feedback popup box.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"

        Expected Result:
        The user is presented with a popup box that allows them to input
        feedback
        """
        self.ps.test_updates['name'] = 't2.18.023' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.023', '58341']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58342 - 024 - Student | Submit feedback for an article
    @pytest.mark.skipif(str(58342) not in TESTS, reason='Excluded')
    def test_student_submit_feedback_for_an_article_58342(self):
        """Submit feedback for an article.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"

        Expected Result:
        A message that says "Thanks for your feedback!" is displayed in the box
        """
        self.ps.test_updates['name'] = 't2.18.024' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.024', '58342']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58343 - 025 - Student | Close window after submitting feedback for an
    # article
    @pytest.mark.skipif(str(58343) not in TESTS, reason='Excluded')
    def test_student_close_window_after_submitting_feedback_for_58343(self):
        """Close window after submitting feedback for an article.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        Enter feedback into the box that pops up
        Click "Submit"
        Click "Close window"

        Expected Result:
        The popup box closes and the message "Thanks for your feedback"
        displays beneath "Feedback"
        """
        self.ps.test_updates['name'] = 't2.18.025' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.025', '58343']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58344 - 026 - Student | Cancel feedback
    @pytest.mark.skipif(str(58344) not in TESTS, reason='Excluded')
    def test_student_cancel_feedback_58344(self):
        """Cancel feedback.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Feedback"
        Click "No"
        [optional] Enter feedback into text box
        Click "Cancel"

        Expected Result:
        The popup box closes
        """
        self.ps.test_updates['name'] = 't2.18.026' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.026', '58344']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58346 - 027 - Student | View related articles
    @pytest.mark.skipif(str(58346) not in TESTS, reason='Excluded')
    def test_student_view_related_articles_58346(self):
        """View related articles.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to "Related Articles"
        Click on one of the articles (if any)

        Expected Result:
        The user is presented with the related article
        """
        self.ps.test_updates['name'] = 't2.18.027' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.027', '58346']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58347 - 028 - Student | Submit a question to Customer Support
    @pytest.mark.skipif(str(58347) not in TESTS, reason='Excluded')
    def test_student_submit_a_question_to_customer_support_58347(self):
        """Submit a question to Customer Support.

        Steps:
        Click "Get Help" from the user menu
        Enter a question or search words into the search engine
        Click "Search" or press enter
        Click on a search result
        Scroll to the bottom of the page
        Click "Contact Us"
        Fill out the required fields
        Enter "Submit"

        Expected Result:
        The message "Thank you for your message! We'll be back to you within
        one business day" is displayed
        """
        self.ps.test_updates['name'] = 't2.18.028' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.028', '58347']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C58348 - 029 - Student | View guided tutorials of Tutor
    @pytest.mark.skipif(str(58348) not in TESTS, reason='Excluded')
    def test_student_view_guided_tutorials_of_tutor_58348(self):
        """View guided tutorial of Tutor.

        Steps:


        Expected Result:

        """
        self.ps.test_updates['name'] = 't2.18.029' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.029', '58348']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        raise NotImplementedError(inspect.currentframe().f_code.co_name)

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

    # C111250 - 030 - User | Faulty URL shows a styled 404 error page
    @pytest.mark.skipif(str(111250) not in TESTS, reason='Excluded')
    def test_user_faulty_url_shows_styled_404_page_111250(self):
        """Faulty URL shows a styled 404 error page.

        Steps:
        go to https://tutor-qa.openstax.org/not_a_real_page

        Expected Result:
        A styled error page is displayed
        """
        self.ps.test_updates['name'] = 't2.18.030' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t2', 't2.18', 't2.18.030', '111250']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.teacher.login()
        self.teacher.get('https://tutor-qa.openstax.org/not_a_real_page')
        self.teacher.wait.until(
            expect.presence_of_element_located((
                By.CSS_SELECTOR,
                '.invalid-page'
            ))
        )

        self.ps.test_updates['passed'] = True
class TestOpenStaxMetrics(unittest.TestCase):
    """CC1.15 - OpenStax Metrics."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        if not LOCAL_RUN:
            self.admin = Admin(
                use_env_vars=True,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities
            )
        else:
            self.admin = Admin(
                use_env_vars=True,
            )

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

    # Case C7608 - 001 - Admin | View a report of enrolled students by course
    @pytest.mark.skipif(str(7608) not in TESTS, reason='Excluded')
    def test_admin_view_a_report_of_enrolled_students_by_course_7608(self):
        """View a report of enrolled students by course.

        Steps:
        Go to Tutor
        Click on the 'Login' button
        Enter the admin user account in the username and password text boxes
        Click on the 'Sign in' button
        Click on the 'Admin' button from the user menu
        Open the drop down menu by clicking 'Course Organization'
        Click the 'Courses' option
        Click the 'List Students' button for the chosen course

        Expected Result:
        List of students for chosen course is displayed
        """
        self.ps.test_updates['name'] = 'cc1.15.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = [
            'cc1',
            'cc1.15',
            'cc1.15.001',
            '7608'
        ]
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.login()
        self.admin.open_user_menu()
        self.admin.find(
            By.LINK_TEXT, 'Admin'
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.find(
            By.LINK_TEXT, 'Course Organization'
        ).click()
        self.admin.find(
            By.LINK_TEXT, 'Courses'
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.find(
            By.LINK_TEXT, 'List Students'
        ).click()
        # assert thaken to correct page
        self.admin.find(
            By.XPATH, '//h1[contains(text(),"Students for course")]'
        )
        assert('student' in self.admin.current_url())
        self.ps.test_updates['passed'] = True
class 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
예제 #14
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 TestContractControls(unittest.TestCase):
    """T1.35 - Contract Controls."""

    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(
            use_env_vars=True,
            pasta_user=self.ps,
            capabilities=self.desired_capabilities
        )
        self.admin.login()
        # make sure there are no new terms to accept
        try:
            self.admin.driver.find_element(
                By.ID, 'i_agree'
            ).click()
            self.admin.driver.find_element(
                By.ID, 'agreement_submit'
            ).click()
        except NoSuchElementException:
            pass
        # go to admin console
        self.wait = WebDriverWait(self.admin.driver, 15)
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.LINK_TEXT, 'Admin')
            )
        ).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Legal")]').click()

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

    # Case C8228 - 001 - Admin | Add a new contract
    @pytest.mark.skipif(str(8228) not in TESTS, reason='Excluded')
    def test_admin_add_a_new_contract_8228(self):
        """Add a new contract.

        Steps:
        Click on the 'Terms' option
        Click on the "New Contract" Link
        Enter information into the Name, Title, and Content text boxes
        Click on the 'Create contract' button

        Expected Result:
        Contract is created as a draft.
        User is shown the contract they just made,
        and has options on what to do with it next
        """
        self.ps.test_updates['name'] = 't1.35.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.001', '8228']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_001')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_001')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_001')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//h1[contains(text(),"Details")]').click()

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

    # Case C8229 - 002 - Admin | Cancel adding a new contract
    @pytest.mark.skipif(str(8229) not in TESTS, reason='Excluded')
    def test_admin_cancel_adding_a_new_contract_8229(self):
        """Cancel adding a new contract.

        Steps:
        Click on the 'Terms' option
        Click on the "New Contract" Link
        Enter information into the Name, Title, and Content text boxes
        Click on the 'Create contract' button
        Click on the Delete link

        Expected Result:
        Contract is deleted. User is taken back to the Contracts page.
        """
        self.ps.test_updates['name'] = 't1.35.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.002', '8229']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_002')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_002')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_002')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="Delete"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH, '//div[contains(@class,"alert-info")]')
        contracts = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_002")]')
        assert(len(contracts) == 0), 'contract not cancled'

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

    # Case C8230 - 003 - Admin | Publish a draft contract
    @pytest.mark.skipif(str(8230) not in TESTS, reason='Excluded')
    def test_admin_publish_a_draft_contract_8230(self):
        """Publish a draft contract.

        Steps:
        Click on the 'Terms' option
        Create a draft contract and return to contract list
        Click on the draft contract
        Click on the Publish link
        Click ok

        Expected Result:
        Draft contract is published
        """
        self.ps.test_updates['name'] = 't1.35.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.003', '8230']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_003')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_003')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_003')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_003")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Publish")]').click()
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(
                    expect.alert_is_present(),
                    'Timed out waiting for alert.'
                )
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

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

    # Case C8231 - 004 - Admin | Delete a draft contract
    @pytest.mark.skipif(str(8231) not in TESTS, reason='Excluded')
    def test_admin_delete_a_draft_contract_8231(self):
        """Delete a draft contract.

        Steps:
        Click on the 'Terms' option
        Create a draft contract and return to the contract list
        Click on the draft contract
        Click on Delete next to chosen draft contract

        Expected Result:
        Draft contract is deleted
        """
        self.ps.test_updates['name'] = 't1.35.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.004', '8231']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        contracts_original = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_004")]')

        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_004')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_004')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_004')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_004")]').click()
        self.admin.page.wait_for_page_load()
        self.admin.sleep(2)
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Delete")]').click()
        self.admin.sleep(2)
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(
                    expect.alert_is_present(),
                    'Timed out waiting for alert.'
                )
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')
        self.admin.page.wait_for_page_load()
        contracts = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"test_contract_title_004")]')
        self.admin.page.wait_for_page_load()
        assert(len(contracts) == len(contracts_original)), \
            'contract not deleted'

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

    # Case C8232 - 005 - Admin | View a current contract
    @pytest.mark.skipif(str(8232) not in TESTS, reason='Excluded')
    def test_admin_view_a_current_contract_8232(self):
        """View a current contract.

        Steps:
        Click on the 'Terms' option
        Create a contract and then return to contract list
        Click on chosen contract

        Expected Result:
        Displays the information of chosen contract.
        """
        self.ps.test_updates['name'] = 't1.35.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.005', '8232']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_005')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_005')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_005')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//li//a[contains(text(),"test_contract_title_005")]').click()
        self.admin.driver.find_element(
            By.XPATH, '//h2[contains(text(),"test_contract_title_005")]')

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

    # Case C8233 - 006 - Admin | Add a new version of a current contract
    @pytest.mark.skipif(str(8233) not in TESTS, reason='Excluded')
    def test_admin_add_a_new_version_of_a_current_contract_8233(self):
        """Add a new version of a current contract.

        Steps:
        Click on the 'Terms' option
        Click on New version next to chosen contract
        Update information in the Name, Title, and Content text boxes.
        Click on the 'Create Contract' button

        Expected Result:
        New version of contract is saved as a draft.
        """
        self.ps.test_updates['name'] = 't1.35.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.006', '8233']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="New Version"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('NEW_006')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('NEW_006')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('NEW_006')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//h2[contains(text(),"NEW_006")]')

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

    # Case C8234 - 007 - Admin | View a contract's signatories
    @pytest.mark.skipif(str(8234) not in TESTS, reason='Excluded')
    def test_admin_view_a_contracts_signatures_8234(self):
        """View a contract's signatories.

        Steps:
        Click on the 'Terms' option
        Click on Signatures next to chosen draft contract

        Expected Result:
        Displays list of signatures for the chosen contract.
        """
        self.ps.test_updates['name'] = 't1.35.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.007', '8234']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        wait = WebDriverWait(self.admin.driver, 45)
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Signatures"]').click()
        wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//div[contains(@class,"signature_index")]')
            )
        )

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

    # Case C8235 - 008 - Admin | Terminate a signatory's contract
    @pytest.mark.skipif(str(8235) not in TESTS, reason='Excluded')
    def test_admin_terminate_a_signnatorys_contract_8235(self):
        """Terminate a signatory's contract.

        Steps:
        Click on the 'Terms' option
        Click on Signatures next to chosen draft contract
        Click on Terminate next to chosen user
        Click on the 'ok' button

        Expected Result:
        Selected user's signing of contract is terminated.
        """
        self.ps.test_updates['name'] = 't1.35.008' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.008', '8235']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Signatures"]').click()
        # is it okay to just terminate some random person's signature
        wait = WebDriverWait(self.admin.driver, 45)
        wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//td//a[contains(text(),"Terminate")]')
            )
        ).click()
        try:
            WebDriverWait(self.admin.driver, 3). \
                until(expect.alert_is_present(),
                      'Timed out waiting for PA creation ' +
                      'confirmation popup to appear.')
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

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

    # Case C8236 - 009 - Admin | Add a targeted contract
    @pytest.mark.skipif(str(8236) not in TESTS, reason='Excluded')
    def test_admin_add_a_targeted_contract_8236(self):
        """Add a targeted contract.

        Steps:
        Click on the 'Targeted Contracts' option
        Click on the 'Add Target Contract' button
        Click the 'Submit' button

        Expected Result:
        User taken back to Targeted contracts page.
        New Targeted Contract is added
        """
        self.ps.test_updates['name'] = 't1.35.009' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.009', '8236']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Targeted Contracts")]')
            )
        ).click()
        orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Add Targeted Contract"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Submit"]').click()
        end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        assert(len(orig_contracts) == len(end_contracts)-1), \
            'targeted contract not added'

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

    # Case C8237 - 010 - Admin | Delete a targeted contract
    @pytest.mark.skipif(str(8237) not in TESTS, reason='Excluded')
    def test_admin_delete_a_targeted_contract_8237(self):
        """Delete a targeted contract.

        Steps:
        Click on the user's name in the top right corner to open drop down menu
        Click on the 'Admin' option of the drop down menu
        Click on 'Legal' on the bar across the top to open drop down menu
        Click on the 'Targeted Contracts' option
        Create a targeted contract and return to the list of targed contracts
        Click on delete next to chosen contract
        Click on the 'ok' button

        Expected Result:
        Targeted contract is deleted
        """
        self.ps.test_updates['name'] = 't1.35.010' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.010', '8237']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Targeted Contracts")]')
            )
        ).click()
        orig_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        # create contract
        self.admin.driver.find_element(
            By.XPATH, '//a[text()="Add Targeted Contract"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Submit"]').click()
        # delete contract
        deletes = self.admin.driver.find_elements(
            By.XPATH, '//a[contains(text(),"delete")]')
        deletes[-1].click()
        try:
            WebDriverWait(self.admin.driver, 3).until(
                expect.alert_is_present(),
                'Timed out waiting for alert.'
            )
            alert = self.admin.driver.switch_to_alert()
            alert.accept()
            print('alert accepted')
        except TimeoutException:
            print('no alert')

        end_contracts = self.admin.driver.find_elements(By.XPATH, '//tr')
        assert(len(orig_contracts) == len(end_contracts)), \
            'targeted contract not added'

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

    # Case C8389 - 011 - Admin | Edit a draft contract
    @pytest.mark.skipif(str(8389) not in TESTS, reason='Excluded')
    def test_admin_edit_a_draft_contract_8389(self):
        """Edit a draft contract.

        Steps:
        Click on the 'Terms' option
        Create a new contract and return to list of contracts
        Click on Edit next to chosen draft contract
        Enter new information into the Name, Title, and Content text boxes
        Click on the 'Update Contract' button

        Expected Result:
        User is taken to Details page for selected contract.
        """
        self.ps.test_updates['name'] = 't1.35.011' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.35', 't1.35.011', '8389']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Terms")]')
            )
        ).click()
        self.admin.driver.find_element(
            By.XPATH,
            '//div[contains(@class,"links")]/a[text()="New Contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//h1[text()="New Contract"]')
            )
        ).click()
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('test_contract_name_011')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('test_contract_title_011')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('test_contract_content_011')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Create contract"]').click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="List"]')
            )
        ).click()
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//li//a[contains(text(),"test_contract_title_011")]')
            )
        ).click()
        self.admin.sleep(1)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//a[text()="Edit"]')
            )
        ).click()
        self.admin.sleep(1)
        self.admin.driver.find_element(
            By.ID, 'contract_name').send_keys('_New')
        self.admin.driver.find_element(
            By.ID, 'contract_title').send_keys('_New')
        self.admin.driver.find_element(
            By.ID, 'contract_content').send_keys('_New')
        self.admin.driver.find_element(
            By.XPATH, '//input[@value="Update contract"]').click()
        self.admin.sleep(1)
        self.admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//h2[contains(text(),"test_contract_title_011_New")]')
            )
        )

        self.ps.test_updates['passed'] = True
    def test_admin_import_content_into_tutor_7604(self):
        """Import content into Tutor.

        Steps:
        Select Customer Analyst from the dropdown menu on the name
        Click on Ecosystems in the header
        Click "Download Manifest" for the desired course
        Scroll down and click Import a new Ecosystem button.
        Click "Choose File"
        Select the downloaded file
        In comment section add today's date and your name. Eg: 2016-03-03 Kajal
        Click on the button Import
        Now wait for at most 5 mins.

        Expected Result:
        The message "Ecosystem import job queued" appears at the top
        """
        self.ps.test_updates['name'] = 'cc1.03.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.03', 'cc1.03.002', '7604']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        if not LOCAL_RUN:
            admin = Admin(
                use_env_vars=True,
                existing_driver=self.content.driver,
                pasta_user=self.ps,
                capabilities=self.desired_capabilities,
            )
        else:
            admin = Admin(
                use_env_vars=True,
                existing_driver=self.content.driver,
            )
        admin.login()
        admin.open_user_menu()
        admin.driver.find_element(By.LINK_TEXT, "Content Analyst").click()
        admin.page.wait_for_page_load()
        admin.driver.find_element(By.LINK_TEXT, "Ecosystems").click()
        # download a manifest to test with
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.LINK_TEXT, "Download Manifest"))).click()
        # import a new ecosystem
        admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        admin.driver.find_element(By.LINK_TEXT,
                                  "Import a new Ecosystem").click()
        # find a downloaded manifest
        home = os.getenv("HOME")
        files = os.listdir(home + '/Downloads')
        file = ''
        for i in range(len(files)):
            if (files[i][-4:] == '.yml'):
                file = files[i]
                break
            else:
                if i == len(files) - 1:
                    print('no .yml file found in downloads')
                    raise Exception
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID,
                 "ecosystem_manifest"))).send_keys(home + '/Downloads/' + file)
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.ID, "ecosystem_comments"))).send_keys(
                    str(datetime.date.today()) + ' automated-admin')
        admin.driver.find_element(By.XPATH, "//input[@type='submit']").click()
        admin.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH, '//div[contains(@class,"alert-info")]')))
        admin.delete()
        self.ps.test_updates['passed'] = True
class TestAccountMaintenance(unittest.TestCase):
    """T1.37 - Account Maintenance."""
    def setUp(self):
        """Pretest settings."""
        self.ps = PastaSauce()
        self.desired_capabilities['name'] = self.id()
        self.admin = Admin(use_env_vars=True,
                           pasta_user=self.ps,
                           capabilities=self.desired_capabilities)
        self.admin.login()
        self.admin.wait = WebDriverWait(self.admin.driver, 15)
        self.admin.open_user_menu()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.LINK_TEXT, 'Admin'))).click()
        self.admin.page.wait_for_page_load()
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Users")]').click()

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

    # Case C8247 - 001 - Admin | Search for a username
    @pytest.mark.skipif(str(8247) not in TESTS, reason='Excluded')
    def test_admin_search_for_a_username_8247(self):
        """Search for a username.

        Steps:
        Enter a username into the search here text box
        Click on the 'Search' button

        Expected Result:
        A list of users with the search term in their name,
        or username is displayed.
        """
        self.ps.test_updates['name'] = 't1.37.001' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.001', '8247']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(By.ID, 'query').send_keys('Atticus')
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//td[contains(text(),"Atticus")]')

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

    # Case C8248 - 002 - Admin | Search for a user's name
    @pytest.mark.skipif(str(8248) not in TESTS, reason='Excluded')
    def test_admin_search_for_a_users_name_8248(self):
        """Search for a user's name.

        Steps:
        Click on the user's name in the top right corner to open drop down menu
        Click on the 'Admin' option of the drop down menu
        Click on 'Users' on the bar across the top
        Enter a user's name into the search here text box
        Click on the 'Search' button

        Expected Result:
        A list of users with the search term in their name,
        or username is displayed.
        """
        self.ps.test_updates['name'] = 't1.37.002' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.002', '8248']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(By.ID, 'query').send_keys('student01')
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        self.admin.driver.find_element(By.XPATH, '//td[text()="student01"]')

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

    # Case C8249 - 003 - Admin | Create a new user
    @pytest.mark.skipif(str(8249) not in TESTS, reason='Excluded')
    def test_admin_create_a_user_8249(self):
        """Create a new user.

        Steps:
        Scroll to the bottom of the page
        Click on the 'Create user' button
        Enter account information into:
        -Username, Password, First name, and Last name text boxes
        Click on the 'Save' button

        Expected Result:
        Takes User back to the Users screen. New user is added.
        """
        self.ps.test_updates['name'] = 't1.37.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.003', '8249']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        num = str(randint(0, 999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.ID,
                                       'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_' + num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # look up account to check that the account was made
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[text()="automated_test_user_' + num + '"]')

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

    # Case C8250 - 004 - Admin | Edit a user
    @pytest.mark.skipif(str(8250) not in TESTS, reason='Excluded')
    def test_admin_edit_a_user_8250(self):
        """Edit a user.

        Steps:
        Create a user to edit
        Enter the user's name into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        Enter new account information into the First name text box
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's information is updated
        """
        self.ps.test_updates['name'] = 't1.37.004' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.004', '8250']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(1000, 1999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.ID,
                                       'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_' + num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]'))).click()
        self.admin.driver.find_element(By.ID,
                                       'user_first_name').send_keys('_EDITED')
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        self.admin.driver.find_element(
            By.XPATH, '//td[contains(text(),"first_name_' + num + '_EDITED")]')

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

    # Case C8251 - 005 - Admin | Assign elevated permissions
    @pytest.mark.skipif(str(8251) not in TESTS, reason='Excluded')
    def test_admin_assign_elevated_permissions_8251(self):
        """Assign elevated permissions.

        Steps:
        Create a user to edit
        Enter the user's username into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        If check box for chosen permission is not checked, click on check box.
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's permissions are modified.
        """
        self.ps.test_updates['name'] = 't1.37.005' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.005', '8251']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(2000, 2999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.ID,
                                       'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_' + num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]'))).click()
        self.admin.driver.find_element(By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'Yes'), \
            'permission not elevated ' + element.get_attribute('innerHTML')

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

    # Case C8252 - 006 - Admin | Remove elevated permissions
    @pytest.mark.skipif(str(8252) not in TESTS, reason='Excluded')
    def test_admin_remove_elevated_permissions_8252(self):
        """Remove elevated permissions.

        Steps:
        Create a user to edit
        Enter the user's name into the search here text box
        Click on the 'Search' button
        Click on the 'Edit' button next to the user
        If check box for chosen permission is checked, click to uncheck it.
        Click on the 'Save' button

        Expected Result:
        User is taken back to the User screen.
        The chosen account's permissions are modified.
        """
        self.ps.test_updates['name'] = 't1.37.006' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.006', '8252']
        self.ps.test_updates['passed'] = False

        # create a user
        num = str(randint(3000, 3999))
        self.admin.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.admin.driver.find_element(
            By.XPATH, '//a[contains(text(),"Create user")]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable((By.ID, 'user_username'))).click()
        self.admin.driver.find_element(
            By.ID, 'user_username').send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.ID,
                                       'user_password').send_keys('password')
        self.admin.driver.find_element(
            By.ID, 'user_first_name').send_keys('first_name_' + num)
        self.admin.driver.find_element(
            By.ID, 'user_last_name').send_keys('last_name_' + num)
        self.admin.driver.find_element(By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for that user
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'Yes'), \
            'permission not elevated ' + element.get_attribute('innerHTML')
        # edit user
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Edit")]'))).click()
        self.admin.driver.find_element(By.ID, 'user_content_analyst').click()
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Save"]').click()
        # search for user to make sure they were updated
        self.admin.wait.until(expect.element_to_be_clickable(
            (By.ID, 'query'))).send_keys('automated_test_user_' + num)
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        element = self.admin.driver.find_element(By.XPATH, '//tr/td[5]')
        assert(element.get_attribute('innerHTML') == 'No'), \
            'permission not elevated ' + element.get_attribute('innerHTML')

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

    # Case C8253 - 007 - Admin | Impersonate a user
    @pytest.mark.skipif(str(8253) not in TESTS, reason='Excluded')
    def test_admin_impersonate_a_user_8253(self):
        """Impersonate a user.

        Steps:
        Click on the 'Sign in as' button next to a user

        Expected Result:
        Signs in as chosen chosen user.
        Goes to chosen users initial screen after login
        (different depending on the user)
        """
        self.ps.test_updates['name'] = 't1.37.007' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['t1', 't1.37', 't1.37.007', '8253']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.admin.driver.find_element(By.ID, 'query').send_keys('student01')
        self.admin.driver.find_element(By.XPATH,
                                       '//input[@value="Search"]').click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//a[contains(text(),"Sign in as")]'))).click()
        self.admin.wait.until(
            expect.element_to_be_clickable(
                (By.XPATH, '//span[contains(text(),"Atticus Finch")]')))

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