Example #1
0
def video_name_persisted(step):
    world.css_click("a.save-button")
    reload_the_page(step)
    world.wait_for_xmodule()
    world.edit_component()

    world.verify_setting_entry(world.get_setting_entry("Display Name"), "Display Name", "3.4", True)
Example #2
0
def create_course_with_unit():
    """
    Prepare for tests by creating a course with a section, subsection, and unit.
    Performs the following:
        Clear out all courseware
        Create a course with a section, subsection, and unit
        Create a user and make that user a course author
        Log the user into studio
        Open the course from the dashboard
        Expand the section and click on the New Unit link
    The end result is the page where the user is editing the new unit
    """
    world.clear_courses()
    course = world.CourseFactory.create()
    world.scenario_dict["COURSE"] = course
    section = world.ItemFactory.create(parent_location=course.location)
    world.ItemFactory.create(parent_location=section.location, category="sequential", display_name="Subsection One")
    user = create_studio_user(is_staff=False)
    add_course_author(user, course)

    log_into_studio()
    world.css_click("a.course-link")

    world.wait_for_js_to_load()
    css_selectors = ["div.section-item a.expand-collapse", "a.new-unit-item"]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()

    assert world.is_css_present("ul.new-component-type")
Example #3
0
def add_a_single_step_component(step):
    world.wait_for_xmodule()
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        css_selector = 'a[data-type="{}"]'.format(component.lower())
        world.css_click(css_selector)
Example #4
0
def video_name_persisted(step):
    world.save_component()
    reload_the_page(step)
    world.wait_for_xmodule()
    world.edit_component()

    world.verify_setting_entry(world.get_setting_entry('Display Name'),
                               'Display Name', '3.4', True)
Example #5
0
def i_created_unit_with_advanced_module(step, advanced_module):
    step.given('I am in Studio editing a new unit')

    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module))
    world.visit(url)
    world.wait_for_xmodule()
def i_created_unit_with_advanced_module(step, advanced_module):
    world.create_course_with_unit()

    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module))
    world.visit(url)
    world.wait_for_xmodule()
Example #7
0
def video_name_persisted(step):
    world.save_component()
    reload_the_page(step)
    world.wait_for_xmodule()
    world.edit_component()

    world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME),
                               DISPLAY_NAME, '3.4', True)
Example #8
0
def video_name_persisted(step):
    world.save_component()
    reload_the_page(step)
    world.wait_for_xmodule()
    world.edit_component()

    world.verify_setting_entry(
        world.get_setting_entry('Display Name'),
        'Display Name', '3.4', True
    )
def video_name_persisted(step):
    world.save_component()
    reload_the_page(step)
    world.wait_for_xmodule()
    world.edit_component()

    world.verify_setting_entry(
        world.get_setting_entry(DISPLAY_NAME),
        DISPLAY_NAME, '3.4', True
    )
Example #10
0
def i_created_a_video_component(step):
    world.create_course_with_unit()
    world.create_component_instance(step=step, category="video")

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present(".is-initialized")
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS["spinner"])
Example #11
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)
    world.wait_for_xmodule()
Example #12
0
def i_created_a_video_component(step):
    step.given("I am in Studio editing a new unit")
    world.create_component_instance(step=step, category="video")

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present(".is-initialized")
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS["spinner"])
    if not world.youtube.config.get("youtube_api_blocked"):
        world.wait_for_visible(SELECTORS["controls"])
Example #13
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given("I have created a Video component")

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)
    world.wait_for_xmodule()
Example #14
0
def i_created_a_video_component(step):
    world.create_course_with_unit()
    world.create_component_instance(
        step=step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
Example #15
0
def i_created_a_video_component(_step):
    world.create_course_with_unit()
    world.create_component_instance(
        step=_step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
Example #16
0
def create_unit_from_course_outline():
    """
    Expands the section and clicks on the New Unit link.
    The end result is the page where the user is editing the new unit.
    """
    css_selectors = [
        '.outline-subsection .expand-collapse', '.outline-subsection .button-new'
    ]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()

    assert world.is_css_present('ul.new-component-type')
Example #17
0
def hide_or_show_captions(step, shown):
    world.wait_for_xmodule()
    button_css = 'a.hide-subtitles'
    if shown == 'hidden':
        world.css_click(button_css)
    if shown == 'toggled':
        world.css_click(button_css)
        # When we click the first time, a tooltip shows up. We want to
        # click the button rather than the tooltip, so move the mouse
        # away to make it disappear.
        button = world.css_find(button_css)
        # mouse_out is not implemented on firefox with selenium
        if not world.is_firefox:
            button.mouse_out()
        world.css_click(button_css)
Example #18
0
def i_created_a_video_component(step):
    step.given('I am in Studio editing a new unit')
    world.create_component_instance(
        step=step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
    if not world.youtube.config.get('youtube_api_blocked'):
        world.wait_for_visible(SELECTORS['controls'])
Example #19
0
def i_created_a_video_component(step):
    step.given('I am in Studio editing a new unit')
    world.create_component_instance(
        step=step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
    if not world.youtube.config.get('youtube_api_blocked'):
        world.wait_for_visible(SELECTORS['controls'])
Example #20
0
def hide_or_show_captions(step, shown):
    world.wait_for_xmodule()
    button_css = "a.hide-subtitles"
    if shown == "hidden":
        world.css_click(button_css)
    if shown == "toggled":
        world.css_click(button_css)
        # When we click the first time, a tooltip shows up. We want to
        # click the button rather than the tooltip, so move the mouse
        # away to make it disappear.
        button = world.css_find(button_css)
        # mouse_out is not implemented on firefox with selenium
        if not world.is_firefox:
            button.mouse_out()
        world.css_click(button_css)
Example #21
0
def add_a_single_step_component(step):
    world.wait_for_xmodule()
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        css_selector = 'a[data-type="{}"]'.format(component.lower())
        world.css_click(css_selector)

        # In the current implementation, all the "new component"
        # buttons are handled by one BackBone.js view.
        # If we click two buttons at super-human speed,
        # the view will miss the second click while it's
        # processing the first.
        # To account for this, we wait for each component
        # to be created before clicking the next component.
        world.wait_for_visible('section.xmodule_{}Module'.format(component))
Example #22
0
def create_unit_from_course_outline():
    """
    Expands the section and clicks on the New Unit link.
    The end result is the page where the user is editing the new unit.
    """
    css_selectors = [
        '.outline-subsection .expand-collapse', '.outline-subsection .button-new'
    ]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()
    world.wait_for_loading()

    assert world.is_css_present('ul.new-component-type')
Example #23
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
Example #24
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
Example #25
0
def i_created_a_video_component(_step):

    assert_less(world.youtube.config['youtube_api_response'].status_code, 400,  "Real Youtube server is unavailable")

    world.create_course_with_unit()
    world.create_component_instance(
        step=_step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
    if not world.youtube.config.get('youtube_api_blocked'):
        world.wait_for_visible(SELECTORS['controls'])
Example #26
0
def i_created_a_video_component(_step):

    assert_less(world.youtube.config['youtube_api_response'].status_code, 400,
                "Real Youtube server is unavailable")

    world.create_course_with_unit()
    world.create_component_instance(
        step=_step,
        category='video',
    )

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
    world.wait_for_invisible(SELECTORS['spinner'])
    if not world.youtube.config.get('youtube_api_blocked'):
        world.wait_for_visible(SELECTORS['controls'])
def create_component_instance(step, component_button_css, category,
                              expected_css, boilerplate=None,
                              has_multiple_templates=True):

    click_new_component_button(step, component_button_css)
    if category in ('problem', 'html'):
        def animation_done(_driver):
            return world.browser.evaluate_script("$('div.new-component').css('display')") == 'none'
        world.wait_for(animation_done)

    if has_multiple_templates:
        click_component_from_menu(category, boilerplate, expected_css)

    if category in ('video',):
        world.wait_for_xmodule()

    assert_equal(
        1,
        len(world.css_find(expected_css)),
        "Component instance with css {css} was not created successfully".format(css=expected_css))
def create_component_instance(step, component_button_css, category,
                              expected_css, boilerplate=None,
                              has_multiple_templates=True):

    click_new_component_button(step, component_button_css)

    if category in ('problem', 'html'):

        def animation_done(_driver):
            script = "$('div.new-component').css('display')"
            return world.browser.evaluate_script(script) == 'none'

        world.wait_for(animation_done)

    if has_multiple_templates:
        click_component_from_menu(category, boilerplate, expected_css)

    if category in ('video',):
        world.wait_for_xmodule()

    assert_true(world.is_css_present(expected_css))
Example #29
0
def delete_components(step, number):
    world.wait_for_xmodule()
    delete_btn_css = 'a.delete-button'
    prompt_css = 'div#prompt-warning'
    btn_css = '{} a.button.action-primary'.format(prompt_css)
    saving_mini_css = 'div#page-notification .wrapper-notification-mini'
    for _ in range(int(number)):
        world.css_click(delete_btn_css)
        assert_true(world.is_css_present('{}.is-shown'.format(prompt_css)),
                    msg='Waiting for the confirmation prompt to be shown')

        # Pressing the button via css was not working reliably for the last component
        # when run in Chrome.
        if world.browser.driver_name is 'Chrome':
            world.browser.execute_script("$('{}').click()".format(btn_css))
        else:
            world.css_click(btn_css)

        # Wait for the saving notification to pop up then disappear
        if world.is_css_present('{}.is-shown'.format(saving_mini_css)):
            world.css_find('{}.is-hiding'.format(saving_mini_css))
Example #30
0
def add_a_multi_step_component(step, is_advanced, category):
    def click_advanced():
        css = 'ul.problem-type-tabs a[href="#tab2"]'
        world.css_click(css)
        my_css = 'ul.problem-type-tabs li.ui-state-active a[href="#tab2"]'
        assert(world.css_find(my_css))

    def find_matching_link():
        """
        Find the link with the specified text. There should be one and only one.
        """
        # The tab shows links for the given category
        links = world.css_find('div.new-component-{} a'.format(category))

        # Find the link whose text matches what you're looking for
        matched_links = [link for link in links if link.text == step_hash['Component']]

        # There should be one and only one
        assert_equal(len(matched_links), 1)
        return matched_links[0]

    def click_link():
        link.click()

    world.wait_for_xmodule()
    category = category.lower()
    for step_hash in step.hashes:
        css_selector = 'a[data-type="{}"]'.format(category)
        world.css_click(css_selector)
        world.wait_for_invisible(css_selector)

        if is_advanced:
            # Sometimes this click does not work if you go too fast.
            world.retry_on_exception(click_advanced, max_attempts=5, ignored_exceptions=AssertionError)

        # Retry this in case the list is empty because you tried too fast.
        link = world.retry_on_exception(func=find_matching_link, ignored_exceptions=AssertionError)

        # Wait for the link to be clickable. If you go too fast it is not.
        world.retry_on_exception(click_link)
Example #31
0
def delete_components(step, number):
    world.wait_for_xmodule()
    delete_btn_css = 'a.delete-button'
    prompt_css = 'div#prompt-warning'
    btn_css = '{} a.button.action-primary'.format(prompt_css)
    saving_mini_css = 'div#page-notification .wrapper-notification-mini'
    for _ in range(int(number)):
        world.css_click(delete_btn_css)
        assert_true(
            world.is_css_present('{}.is-shown'.format(prompt_css)),
            msg='Waiting for the confirmation prompt to be shown')

        # Pressing the button via css was not working reliably for the last component
        # when run in Chrome.
        if world.browser.driver_name is 'Chrome':
            world.browser.execute_script("$('{}').click()".format(btn_css))
        else:
            world.css_click(btn_css)

        # Wait for the saving notification to pop up then disappear
        if world.is_css_present('{}.is-shown'.format(saving_mini_css)):
            world.css_find('{}.is-hiding'.format(saving_mini_css))
Example #32
0
def create_course_with_unit():
    """
    Prepare for tests by creating a course with a section, subsection, and unit.
    Performs the following:
        Clear out all courseware
        Create a course with a section, subsection, and unit
        Create a user and make that user a course author
        Log the user into studio
        Open the course from the dashboard
        Expand the section and click on the New Unit link
    The end result is the page where the user is editing the new unit
    """
    world.clear_courses()
    course = world.CourseFactory.create()
    world.scenario_dict['COURSE'] = course
    section = world.ItemFactory.create(parent_location=course.location)
    world.ItemFactory.create(
        parent_location=section.location,
        category='sequential',
        display_name='Subsection One',
    )
    user = create_studio_user(is_staff=False)
    add_course_author(user, course)

    log_into_studio()
    world.css_click('a.course-link')

    world.wait_for_js_to_load()
    css_selectors = [
        'div.section-item a.expand-collapse-icon', 'a.new-unit-item'
    ]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()

    assert world.is_css_present('ul.new-component-type')
Example #33
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()

    # update .sub filed with proper subs name (which mimics real Studio/XML behavior)
    # this is needed only for that videos which are created in acceptance tests.
    _step.given('I edit the component')
    world.wait_for_ajax_complete()
    _step.given('I save changes')

    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
Example #34
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()

    # update .sub filed with proper subs name (which mimics real Studio/XML behavior)
    # this is needed only for that videos which are created in acceptance tests.
    _step.given('I edit the component')
    world.wait_for_ajax_complete()
    _step.given('I save changes')

    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
Example #35
0
def delete_all_components(step):
    world.wait_for_xmodule()
    delete_btn_css = "a.delete-button"
    prompt_css = "div#prompt-warning"
    btn_css = "{} a.button.action-primary".format(prompt_css)
    saving_mini_css = "div#page-notification .wrapper-notification-mini"
    count = len(world.css_find("ol.components li.component"))
    for _ in range(int(count)):
        world.css_click(delete_btn_css)
        assert_true(
            world.is_css_present("{}.is-shown".format(prompt_css)),
            msg="Waiting for the confirmation prompt to be shown",
        )

        # Pressing the button via css was not working reliably for the last component
        # when run in Chrome.
        if world.browser.driver_name is "Chrome":
            world.browser.execute_script("$('{}').click()".format(btn_css))
        else:
            world.css_click(btn_css)

        # Wait for the saving notification to pop up then disappear
        if world.is_css_present("{}.is-shown".format(saving_mini_css)):
            world.css_find("{}.is-hiding".format(saving_mini_css))
Example #36
0
def enable_latex_compiler(step):
    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, 'use_latex_compiler', True)
    world.visit(url)
    world.wait_for_xmodule()
Example #37
0
def the_youtube_video_is_shown(_step):
    world.wait_for_xmodule()
    ele = world.css_find('.video').first
    assert ele['data-streams'].split(':')[1] == world.scenario_dict['YOUTUBE_ID']
Example #38
0
def the_youtube_video_is_shown(_step):
    world.wait_for_xmodule()
    ele = world.css_find(".video").first
    assert ele["data-streams"].split(":")[1] == world.scenario_dict["YOUTUBE_ID"]
Example #39
0
def does_not_autoplay(_step, video_type):
    world.wait_for_xmodule()
    assert world.css_find(".%s" % video_type)[0]["data-autoplay"] == "False"
    assert world.css_has_class(".video_control", "play")
Example #40
0
def the_youtube_video_is_shown(_step):
    world.wait_for_xmodule()
    ele = world.css_find('.video').first
    assert ele['data-streams'].split(':')[1] == world.scenario_dict['YOUTUBE_ID']
Example #41
0
def does_not_autoplay(_step, video_type):
    world.wait_for_xmodule()
    assert world.css_find('.%s' % video_type)[0]['data-autoplay'] == 'False'
    assert world.css_has_class('.video_control', 'play')
Example #42
0
def does_not_autoplay(_step, video_type):
    world.wait_for_xmodule()
    assert world.css_find('.%s' % video_type)[0]['data-autoplay'] == 'False'
    assert world.css_has_class('.video_control', 'play')
def enable_latex_compiler(step):
    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, 'Enable LaTeX Compiler', 'true')
    world.visit(url)
    world.wait_for_xmodule()