Esempio n. 1
0
 def play(self):
     """
     Start playing the video.
     """
     with fulfill_after(
             EmptyPromise(lambda: self.is_playing, "Video is playing")):
         self.css_click('a.video_control.play')
Esempio n. 2
0
 def pause(self):
     """
     Pause the video.
     """
     with fulfill_after(
             EmptyPromise(lambda: self.is_paused, "Video is paused")):
         self.css_click('a.video_control.pause')
Esempio n. 3
0
 def submit_response(self):
     """
     Submit a response for grading.
     """
     with fulfill_after(self._submitted_promise(self.assessment_type)):
         with self.handle_alert():
             self.css_click('input.submit-button')
Esempio n. 4
0
 def submit_response(self):
     """
     Submit a response for grading.
     """
     with fulfill_after(self._submitted_promise(self.assessment_type)):
         with self.handle_alert():
             self.css_click('input.submit-button')
Esempio n. 5
0
 def pause(self):
     """
     Pause the video.
     """
     with fulfill_after(
         EmptyPromise(lambda: self.is_paused, "Video is paused")
     ):
         self.css_click('a.video_control.pause')
Esempio n. 6
0
 def play(self):
     """
     Start playing the video.
     """
     with fulfill_after(
         EmptyPromise(lambda: self.is_playing, "Video is playing")
     ):
         self.css_click('a.video_control.play')
Esempio n. 7
0
    def save_response(self):
        """
        Save the response for later submission.
        """
        status_msg_shown = EmptyPromise(
            lambda: 'save' in self.alert_message.lower(),
            "Status message saved")

        with fulfill_after(status_msg_shown):
            self.css_click('input.save-button')
Esempio n. 8
0
    def save_response(self):
        """
        Save the response for later submission.
        """
        status_msg_shown = EmptyPromise(
            lambda: 'save' in self.alert_message.lower(),
            "Status message saved"
        )

        with fulfill_after(status_msg_shown):
            self.css_click('input.save-button')
Esempio n. 9
0
    def login(self, email, password):
        """
        Attempt to log in using `email` and `password`.
        """

        # Ensure that we make it to another page
        on_next_page = EmptyPromise(lambda: "login" not in self.browser.url,
                                    "redirected from the login page")

        with fulfill_after(on_next_page):
            self.css_fill('input#email', email)
            self.css_fill('input#password', password)
            self.css_click('button#submit')
Esempio n. 10
0
    def login(self, email, password):
        """
        Attempt to log in using `email` and `password`.
        """
        # Ensure that we make it to another page
        on_next_page = EmptyPromise(
            lambda: "login" not in self.browser.url,
            "redirected from the login page"
        )

        with fulfill_after(on_next_page):
            self.css_fill('input#email', email)
            self.css_fill('input#password', password)
            self.css_click('button#submit')
Esempio n. 11
0
    def go_to_tab(self, tab_name):
        """
        Navigate to the tab `tab_name`.
        """
        if tab_name not in ['Courseware', 'Course Info', 'Discussion', 'Wiki', 'Progress']:
            self.warning("'{0}' is not a valid tab name".format(tab_name))

        # The only identifier for individual tabs is the link href
        # so we find the tab with `tab_name` in its text.
        tab_css = self._tab_css(tab_name)

        with fulfill_after(self._is_on_tab_promise(tab_name)):
            if tab_css is not None:
                self.css_click(tab_css)
            else:
                self.warning("No tabs found for '{0}'".format(tab_name))
Esempio n. 12
0
    def go_to_tab(self, tab_name):
        """
        Navigate to the tab `tab_name`.
        """
        if tab_name not in [
                'Courseware', 'Course Info', 'Discussion', 'Wiki', 'Progress'
        ]:
            self.warning("'{0}' is not a valid tab name".format(tab_name))

        # The only identifier for individual tabs is the link href
        # so we find the tab with `tab_name` in its text.
        tab_css = self._tab_css(tab_name)

        with fulfill_after(self._is_on_tab_promise(tab_name)):
            if tab_css is not None:
                self.css_click(tab_css)
            else:
                self.warning("No tabs found for '{0}'".format(tab_name))
Esempio n. 13
0
    def trigger_output(self):
        """
        Wait for click handlers to be installed,
        then click a button and retrieve the output that appears
        after a delay.
        """

        click_ready = EmptyPromise(
            lambda: self.is_css_present('div#ready'), "Click ready"
        )

        output_ready = EmptyPromise(
            lambda: self.is_css_present('div#output'), "Output available"
        )

        with fulfill_after(output_ready):
            with fulfill_before(click_ready):
                self.css_click('div#fixture button')
Esempio n. 14
0
    def go_to_section(self, section_title, subsection_title):
        """
        Go to the section in the courseware.
        Every section must have at least one subsection, so specify
        both the section and subsection title.

        Example:
            go_to_section("Week 1", "Lesson 1")
        """

        # For test stability, disable JQuery animations (opening / closing menus)
        self.disable_jquery_animations()

        # Get the section by index
        try:
            sec_index = self._section_titles().index(section_title)
        except ValueError:
            self.warning("Could not find section '{0}'".format(section_title))
            return

        # Click the section to ensure it's open (no harm in clicking twice if it's already open)
        # Add one to convert from list index to CSS index
        section_css = 'nav>div.chapter:nth-of-type({0})>h3>a'.format(
            sec_index + 1)
        self.css_click(section_css)

        # Get the subsection by index
        try:
            subsec_index = self._subsection_titles(sec_index +
                                                   1).index(subsection_title)
        except ValueError:
            msg = "Could not find subsection '{0}' in section '{1}'".format(
                subsection_title, section_title)
            self.warning(msg)
            return

        # Convert list indices (start at zero) to CSS indices (start at 1)
        subsection_css = "nav>div.chapter:nth-of-type({0})>ul>li:nth-of-type({1})>a".format(
            sec_index + 1, subsec_index + 1)

        # Click the subsection and ensure that the page finishes reloading
        with fulfill_after(
                self._on_section_promise(section_title, subsection_title)):
            self.css_click(subsection_css)
Esempio n. 15
0
    def go_to_section(self, section_title, subsection_title):
        """
        Go to the section in the courseware.
        Every section must have at least one subsection, so specify
        both the section and subsection title.

        Example:
            go_to_section("Week 1", "Lesson 1")
        """

        # For test stability, disable JQuery animations (opening / closing menus)
        self.disable_jquery_animations()

        # Get the section by index
        try:
            sec_index = self._section_titles().index(section_title)
        except ValueError:
            self.warning("Could not find section '{0}'".format(section_title))
            return

        # Click the section to ensure it's open (no harm in clicking twice if it's already open)
        # Add one to convert from list index to CSS index
        section_css = 'nav>div.chapter:nth-of-type({0})>h3>a'.format(sec_index + 1)
        self.css_click(section_css)

        # Get the subsection by index
        try:
            subsec_index = self._subsection_titles(sec_index + 1).index(subsection_title)
        except ValueError:
            msg = "Could not find subsection '{0}' in section '{1}'".format(subsection_title, section_title)
            self.warning(msg)
            return

        # Convert list indices (start at zero) to CSS indices (start at 1)
        subsection_css = "nav>div.chapter:nth-of-type({0})>ul>li:nth-of-type({1})>a".format(
            sec_index + 1, subsec_index + 1
        )

        # Click the subsection and ensure that the page finishes reloading
        with fulfill_after(self._on_section_promise(section_title, subsection_title)):
            self.css_click(subsection_css)