コード例 #1
0
ファイル: enrollment.py プロジェクト: openstax/os-automation
    def purchase(self) -> Union[PurchaseConfirmation]:
        """Click on the 'Purchase' Tutor button.

        :return: the purchase confirmation modal or the error message for a
            failed transaction
        :rtype: :py:class:`~pages.tutor.enrollment.PurchaseConfirmation`
        :raises: :py:class:`~utils.tutor.TutorException` if error messages are
            found

        """
        purchase = self.find_element(*self._base_iframe_locator)
        self.driver.switch_to.frame(purchase)
        button = self.wait.until(
            expect.presence_of_element_located(self._purchase_button_locator))
        sleep(0.25)
        is_not_chrome = not Utility.is_browser(self.driver, 'chrome')
        Utility.click_option(self.driver,
                             element=button,
                             force_js_click=is_not_chrome)
        sleep(1)
        self.driver.switch_to.default_content()
        errors = self.error_messages
        if errors:
            raise TutorException(errors)
        return PurchaseConfirmation(self.page)
コード例 #2
0
        def copy_this_course(self):
            """Clone the selected course.

            :return: the course cloning wizard
            :rtype: :py:class:`~pages.tutor.new_course.CloneCourse`

            """
            assert(self.is_teacher), \
                "Only verified instructors may clone a course"
            assert(not self.is_preview), \
                "Preview courses may not be cloned"
            if Utility.is_browser(self.driver, 'safari'):
                button = self.find_element(By.CSS_SELECTOR, '.btn-sm')
                Utility.click_option(self.driver, element=button)
            else:
                from selenium.webdriver.common.action_chains import \
                    ActionChains
                Utility.scroll_to(self.driver, element=self.root, shift=-80)
                ActionChains(self.driver) \
                    .move_to_element(self.course_brand) \
                    .pause(1) \
                    .move_to_element(
                        self.find_element(By.CSS_SELECTOR, '.btn-sm')) \
                    .pause(1) \
                    .click() \
                    .perform()
            from pages.tutor.new_course import CloneCourse
            return go_to_(CloneCourse(self.driver, self.page.page.base_url))
コード例 #3
0
ファイル: enrollment.py プロジェクト: openstax/os-automation
    def loaded(self) -> bool:
        """Return True when the content is present in the iframe.

        :return: ``True`` when the content in the payment confirmation iframe
            is present
        :rtype: bool

        """
        if Utility.is_browser(self.driver, 'chrome'):
            return bool(self.order_number) and bool(self.total)
        else:
            return sleep(3.0) or True
コード例 #4
0
ファイル: enrollment.py プロジェクト: openstax/os-automation
    def access_your_course(self) -> StudentCourse:
        """Click the 'Access your course' continuation button.

        :return: the student course page
        :rtype: :py:class:`~pages.tutor.course.StudentCourse`

        """
        confirmation = self.find_element(*self._base_iframe_locator)
        self.driver.switch_to.frame(confirmation)
        button = self.find_element(*self._access_your_course_button_locator)
        is_not_chrome = not Utility.is_browser(self.driver, 'chrome')
        Utility.click_option(self.driver,
                             element=button,
                             force_js_click=is_not_chrome)
        self.driver.switch_to.default_content()
        return go_to_(StudentCourse(self.driver, base_url=self.page.base_url))
コード例 #5
0
        def go_to_course(self):
            """Go to the course page for this course.

            :return: the calendar (teacher) or current week (student) page for
                the selected course
            :rtype: :py:class:`~pages.tutor.calendar.Calendar` or
                :py:class:`~pages.tutor.course.StudentCourse`

            """
            if self.is_teacher:
                from pages.tutor.calendar import Calendar as Destination
            else:
                from pages.tutor.course import StudentCourse as Destination
            if Utility.is_browser(self.driver, 'safari'):
                card = self.find_element(*self._card_safari_locator)
            else:
                card = self.find_element(*self._card_locator)
            Utility.click_option(self.driver, element=card)
            return go_to_(Destination(self.driver, self.page.page.base_url))
コード例 #6
0
    def answer(self, multipart: bool = False) -> None:
        """Click the 'Answer' button.

        :param bool multipart: if ``True``, skip the staleness check because
            the screen doesn't change between multi-part assessment questions
        :return: None

        """
        sleep(0.33)
        Utility.click_option(self.driver, element=self.answer_button)
        if not multipart:
            sleep(1)
            if Utility.is_browser(self.driver, 'safari'):
                sleep(3)
            else:
                try:
                    self.wait.until(lambda _: self._check_button())
                except StaleElementReferenceException:
                    pass
                except TimeoutException:
                    return
        else:
            sleep(1.5)
        sleep(1)