Example #1
0
 def view_gst(self, step):
     r'I view the Graphical Slider Tool$'
     visit_scenario_item('GST')
     world.wait_for_js_variable_truthy(
         '$(".xblock-student_view[data-type=GraphicalSliderTool]").data("initialized")'
     )
     world.wait_for_ajax_complete()
Example #2
0
    def check_rendered(self, step):
        r"""the annotatable component has rendered$"""
        world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=Annotatable]").data("initialized")')
        annotatable_text = world.css_find('.xblock-student_view[data-type=Annotatable]').first.text
        assert_in("Instruction text", annotatable_text)

        for i in xrange(self.annotations_count):
            assert_in("Region Contents {}".format(i), annotatable_text)
Example #3
0
def wait_for_js_to_load():
    for test, req in REQUIREJS_WAIT.items():
        if test.search(world.browser.title):
            world.wait_for_requirejs(req)
            break

    for test, req in TRUTHY_WAIT.items():
        if test.search(world.browser.title):
            for var in req:
                world.wait_for_js_variable_truthy(var)
Example #4
0
def wait_for_js_to_load():
    for test, req in REQUIREJS_WAIT.items():
        if test.search(world.browser.title):
            world.wait_for_requirejs(req)
            break

    for test, req in TRUTHY_WAIT.items():
        if test.search(world.browser.title):
            for var in req:
                world.wait_for_js_variable_truthy(var)
Example #5
0
def shows_captions(_step, show_captions):
    world.wait_for_js_variable_truthy("Video")
    world.wait(0.5)
    if show_captions == 'does not':
        assert_true(world.is_css_present('div.video.closed'))
    else:
        assert_true(world.is_css_not_present('div.video.closed'))

    # Prevent cookies from overriding course settings
    world.browser.cookies.delete('hide_captions')
    world.browser.cookies.delete('current_player_mode')
Example #6
0
def shows_captions(_step, show_captions):
    world.wait_for_js_variable_truthy("Video")
    world.wait(0.5)
    if show_captions == 'does not':
        assert_true(world.is_css_present('div.video.closed'))
    else:
        assert_true(world.is_css_not_present('div.video.closed'))

    # Prevent cookies from overriding course settings
    world.browser.cookies.delete('hide_captions')
    world.browser.cookies.delete('current_player_mode')
Example #7
0
def shows_captions(_step, show_captions):
    world.wait_for_js_variable_truthy("Video")
    world.wait(0.5)
    if show_captions == "does not":
        assert world.is_css_present("div.video.closed")
    else:
        assert world.is_css_not_present("div.video.closed")

    # Prevent cookies from overriding course settings
    world.browser.cookies.delete("hide_captions")
    world.browser.cookies.delete("current_player_mode")
Example #8
0
    def answer_poll(self, step, answer):
        r' I answer the conditioned poll "([^"]*)"$'
        visit_scenario_item("CONDITION_SOURCE")
        world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=Poll]").data("initialized")')
        world.wait_for_ajax_complete()

        answer_text = [
            poll_answer["text"]
            for poll_answer in world.scenario_dict["CONDITION_SOURCE"].answers
            if poll_answer["id"] == answer
        ][0]

        text_selector = ".poll_answer .text"

        poll_texts = world.retry_on_exception(lambda: [elem.text for elem in world.css_find(text_selector)])

        for idx, poll_text in enumerate(poll_texts):
            if poll_text == answer_text:
                world.css_click(text_selector, index=idx)
                return
Example #9
0
    def answer_poll(self, step, answer):
        r' I answer the conditioned poll "([^"]*)"$'
        visit_scenario_item('CONDITION_SOURCE')
        world.wait_for_js_variable_truthy(
            '$(".xblock-student_view[data-type=Poll]").data("initialized")')
        world.wait_for_ajax_complete()

        answer_text = [
            poll_answer['text']
            for poll_answer in world.scenario_dict['CONDITION_SOURCE'].answers
            if poll_answer['id'] == answer
        ][0]

        text_selector = '.poll_answer .text'

        poll_texts = world.retry_on_exception(
            lambda: [elem.text for elem in world.css_find(text_selector)])

        for idx, poll_text in enumerate(poll_texts):
            if poll_text == answer_text:
                world.css_click(text_selector, index=idx)
                return
def i_select_advanced_settings(step):

    world.wait_for_js_to_load()  # pylint: disable=no-member
    world.wait_for_js_variable_truthy('window.studioNavMenuActive')  # pylint: disable=no-member

    for _ in range(5):
        world.click_course_settings()  # pylint: disable=no-member

        # The click handlers are set up so that if you click <body>
        # the menu disappears.  This means that if we're even a *little*
        # bit off on the last item ('Advanced Settings'), the menu
        # will close and the test will fail.
        # For this reason, we retrieve the link and visit it directly
        # This is what the browser *should* be doing, since it's just a native
        # link with no JavaScript involved.
        link_css = 'li.nav-course-settings-advanced a'
        try:
            world.wait_for_visible(link_css)  # pylint: disable=no-member
            break
        except AssertionError:
            continue

    link = world.css_find(link_css).first['href']
    world.visit(link)
def i_select_advanced_settings(step):

    world.wait_for_js_to_load()  # pylint: disable=no-member
    world.wait_for_js_variable_truthy('window.studioNavMenuActive')  # pylint: disable=no-member

    for _ in range(5):
        world.click_course_settings()  # pylint: disable=no-member

        # The click handlers are set up so that if you click <body>
        # the menu disappears.  This means that if we're even a *little*
        # bit off on the last item ('Advanced Settings'), the menu
        # will close and the test will fail.
        # For this reason, we retrieve the link and visit it directly
        # This is what the browser *should* be doing, since it's just a native
        # link with no JavaScript involved.
        link_css = 'li.nav-course-settings-advanced a'
        try:
            world.wait_for_visible(link_css)  # pylint: disable=no-member
            break
        except AssertionError:
            continue

    link = world.css_find(link_css).first['href']
    world.visit(link)
Example #12
0
 def view_gst(self, step):
     r'I view the Graphical Slider Tool$'
     visit_scenario_item('GST')
     world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=GraphicalSliderTool]").data("initialized")')
     world.wait_for_ajax_complete()
Example #13
0
def wait_for_mathjax():
    "Wait until MathJax is loaded and set up on the page."
    world.wait_for_js_variable_truthy("MathJax.isReady")
Example #14
0
def wait_for_xmodule():
    "Wait until the XModule Javascript has loaded on the page."
    world.wait_for_js_variable_truthy("XModule")
    world.wait_for_js_variable_truthy("XBlock")
Example #15
0
def wait_for_mathjax():
    "Wait until MathJax is loaded and set up on the page."
    world.wait_for_js_variable_truthy("MathJax.isReady")
Example #16
0
def wait_for_xmodule():
    "Wait until the XModule Javascript has loaded on the page."
    world.wait_for_js_variable_truthy("XModule")
    world.wait_for_js_variable_truthy("XBlock")
Example #17
0
 def when_i_view_the_conditional(self, step):
     r"I view the conditional$"
     visit_scenario_item("CONDITIONAL")
     world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=Conditional]").data("initialized")')
Example #18
0
 def when_i_view_the_conditional(self, step):
     r'I view the conditional$'
     visit_scenario_item('CONDITIONAL')
     world.wait_for_js_variable_truthy(
         '$(".xblock-student_view[data-type=Conditional]").data("initialized")'
     )