示例#1
0
def _do_studio_prompt_action(intent, action):
    """
    Wait for a studio prompt to appear and press the specified action button
    See common/js/components/views/feedback_prompt.js for implementation
    """
    assert intent in [
        'warning',
        'error',
        'confirmation',
        'announcement',
        'step-required',
        'help',
        'mini',
    ]
    assert action in ['primary', 'secondary']

    world.wait_for_present(
        'div.wrapper-prompt.is-shown#prompt-{}'.format(intent))

    action_css = 'li.nav-item > button.action-{}'.format(action)
    world.trigger_event(action_css, event='focus')
    world.browser.execute_script("$('{}').click()".format(action_css))

    world.wait_for_ajax_complete()
    world.wait_for_present(
        'div.wrapper-prompt.is-hiding#prompt-{}'.format(intent))
示例#2
0
def add_video_to_course(course, parent_location=None, player_mode=None, data=None, display_name='Video'):
    if not parent_location:
        parent_location = add_vertical_to_course(course)
    kwargs = get_metadata(parent_location, player_mode, data, display_name=display_name)
    world.scenario_dict['VIDEO'] = world.ItemFactory.create(**kwargs)
    world.wait_for_present('.is-initialized')
    world.wait_for_invisible('.video-wrapper .spinner')
    world.wait_for_ajax_complete()
示例#3
0
def lti_is_rendered_iframe(_step):
    world.wait_for_present('iframe')  # pylint: disable=no-member
    assert world.is_css_present('iframe', wait_time=2)  # pylint: disable=no-member
    assert not world.is_css_present('.link_lti_new_window', wait_time=0)  # pylint: disable=no-member
    assert not world.is_css_present('.error_message', wait_time=0)  # pylint: disable=no-member

    # iframe is visible
    assert world.css_visible('iframe')  # pylint: disable=no-member
    check_lti_iframe_content("This is LTI tool. Success.")
示例#4
0
def lti_is_rendered_iframe(_step):
    world.wait_for_present('iframe')  # pylint: disable=no-member
    assert world.is_css_present('iframe', wait_time=2)  # pylint: disable=no-member
    assert not world.is_css_present('.link_lti_new_window', wait_time=0)  # pylint: disable=no-member
    assert not world.is_css_present('.error_message', wait_time=0)  # pylint: disable=no-member

    # iframe is visible
    assert world.css_visible('iframe')  # pylint: disable=no-member
    check_lti_iframe_content("This is LTI tool. Success.")
示例#5
0
def delete_file(_step, file_name):
    index = get_index(file_name)
    assert index != -1
    delete_css = "a.remove-asset-button"
    world.css_click(delete_css, index=index)

    world.wait_for_present(".wrapper-prompt.is-shown")
    world.wait(0.2)  # wait for css animation
    prompt_confirm_css = 'li.nav-item > a.action-primary'
    world.css_click(prompt_confirm_css)
示例#6
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"])
示例#7
0
def add_video_to_course(course, parent_location=None, player_mode=None, data=None, display_name='Video'):

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

    if not parent_location:
        parent_location = add_vertical_to_course(course)
    kwargs = get_metadata(parent_location, player_mode, data, display_name=display_name)
    world.scenario_dict['VIDEO'] = world.ItemFactory.create(**kwargs)
    world.wait_for_present('.is-initialized')
    world.wait_for_invisible('.video-wrapper .spinner')
    world.wait_for_ajax_complete()
示例#8
0
def check_role(_step, role):
    world.wait_for_present('iframe')
    location = world.scenario_dict['LTI'].location.html_id()
    iframe_name = 'ltiFrame-' + location
    with world.browser.get_iframe(iframe_name) as iframe:
        expected_role = 'Role: ' + role
        role = world.retry_on_exception(
            lambda: iframe.find_by_tag('h5').first.value,
            max_attempts=5,
            ignored_exceptions=ElementDoesNotExist)
        assert_equal(expected_role, role)
示例#9
0
def check_role(_step, role):
    world.wait_for_present('iframe')
    location = world.scenario_dict['LTI'].location.html_id()
    iframe_name = 'ltiFrame-' + location
    with world.browser.get_iframe(iframe_name) as iframe:
        expected_role = 'Role: ' + role
        role = world.retry_on_exception(
            lambda: iframe.find_by_tag('h5').first.value,
            max_attempts=5,
            ignored_exceptions=ElementDoesNotExist
        )
        assert_equal(expected_role, role)
示例#10
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"])
示例#11
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'])
示例#12
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'])
示例#13
0
def add_video_to_course(course, player_mode, hashes, display_name='Video'):
    category = 'video'

    kwargs = {
        'parent_location': section_location(course),
        'category': category,
        'display_name': display_name,
        'metadata': {},
    }

    if hashes:
        kwargs['metadata'].update(hashes[0])

    conversions = {
        'transcripts': json.loads,
        'download_track': json.loads,
        'download_video': json.loads,
    }

    for key in kwargs['metadata']:
        if key in conversions:
            kwargs['metadata'][key] = conversions[key](kwargs['metadata'][key])

    if player_mode == 'html5':
        kwargs['metadata'].update({
            'youtube_id_1_0': '',
            'youtube_id_0_75': '',
            'youtube_id_1_25': '',
            'youtube_id_1_5': '',
            'html5_sources': HTML5_SOURCES
        })
    if player_mode == 'youtube_html5':
        kwargs['metadata'].update({
            'html5_sources': HTML5_SOURCES,
        })
    if player_mode == 'youtube_html5_unsupported_video':
        kwargs['metadata'].update({
            'html5_sources': HTML5_SOURCES_INCORRECT
        })
    if player_mode == 'html5_unsupported_video':
        kwargs['metadata'].update({
            'youtube_id_1_0': '',
            'youtube_id_0_75': '',
            'youtube_id_1_25': '',
            'youtube_id_1_5': '',
            'html5_sources': HTML5_SOURCES_INCORRECT
        })

    world.scenario_dict['VIDEO'] = world.ItemFactory.create(**kwargs)
    world.wait_for_present('.is-initialized')
    world.wait_for_invisible('.video-wrapper .spinner')
示例#14
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)

    # Wait for the css animation to apply the is-shown class
    shown_css = 'div.wrapper-create-user.is-shown'
    world.wait_for_present(shown_css)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + '@edx.org')
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#15
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)

    # Wait for the css animation to apply the is-shown class
    shown_css = 'div.wrapper-create-user.is-shown'
    world.wait_for_present(shown_css)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + '@edx.org')
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#16
0
def select_language(_step, code):
    selector = VIDEO_MENUS["language"] + ' li[data-lang-code="{code}"]'.format(
        code=code
    )

    world.wait_for_present(selector)
    world.css_find(VIDEO_BUTTONS["CC"])[0].mouse_over()
    world.wait_for_visible(selector)
    world.css_click(selector)

    assert world.css_has_class(selector, 'active')
    assert len(world.css_find(VIDEO_MENUS["language"] + ' li.active')) == 1
    assert world.css_visible('.subtitles')
    world.wait_for_ajax_complete()
示例#17
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'])
示例#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'])
示例#19
0
def add_video_to_course(course,
                        parent_location=None,
                        player_mode=None,
                        data=None,
                        display_name='Video'):
    if not parent_location:
        parent_location = add_vertical_to_course(course)
    kwargs = get_metadata(parent_location,
                          player_mode,
                          data,
                          display_name=display_name)
    world.scenario_dict['VIDEO'] = world.ItemFactory.create(**kwargs)
    world.wait_for_present('.is-initialized')
    world.wait_for_invisible('.video-wrapper .spinner')
    world.wait_for_ajax_complete()
示例#20
0
def _do_studio_prompt_action(intent, action):
    """
    Wait for a studio prompt to appear and press the specified action button
    See cms/static/js/views/feedback_prompt.js for implementation
    """
    assert intent in ["warning", "error", "confirmation", "announcement", "step-required", "help", "mini"]
    assert action in ["primary", "secondary"]

    world.wait_for_present("div.wrapper-prompt.is-shown#prompt-{}".format(intent))

    action_css = "li.nav-item > a.action-{}".format(action)
    world.trigger_event(action_css, event="focus")
    world.browser.execute_script("$('{}').click()".format(action_css))

    world.wait_for_ajax_complete()
    world.wait_for_present("div.wrapper-prompt.is-hiding#prompt-{}".format(intent))
示例#21
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'])
示例#22
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'])
示例#23
0
def _do_studio_prompt_action(intent, action):
    """
    Wait for a studio prompt to appear and press the specified action button
    See cms/static/js/views/feedback_prompt.js for implementation
    """
    assert intent in ['warning', 'error', 'confirmation', 'announcement',
        'step-required', 'help', 'mini']
    assert action in ['primary', 'secondary']

    world.wait_for_present('div.wrapper-prompt.is-shown#prompt-{}'.format(intent))

    action_css = 'li.nav-item > a.action-{}'.format(action)
    world.trigger_event(action_css, event='focus')
    world.browser.execute_script("$('{}').click()".format(action_css))

    world.wait_for_ajax_complete()
    world.wait_for_present('div.wrapper-prompt.is-hiding#prompt-{}'.format(intent))
示例#24
0
def lti_is_rendered(_step, rendered_in):
    if rendered_in.strip() == 'iframe':
        world.wait_for_present('iframe')
        assert world.is_css_present('iframe', wait_time=2)
        assert not world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)

        # iframe is visible
        assert world.css_visible('iframe')
        check_lti_iframe_content("This is LTI tool. Success.")

    elif rendered_in.strip() == 'new page':
        assert not world.is_css_present('iframe', wait_time=2)
        assert world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)
        click_and_check_lti_popup()
    else:  # incorrect rendered_in parameter
        assert False
示例#25
0
def select_language(_step, code):
    # Make sure that all ajax requests that affects the language menu are finished.
    # For example, request to get new translation etc.
    world.wait_for_ajax_complete()
    selector = VIDEO_MENUS["language"] + ' li[data-lang-code="{code}"]'.format(code=code)

    world.css_find(VIDEO_BUTTONS["CC"])[0].mouse_over()
    world.wait_for_present(".lang.open")
    world.css_click(selector)

    assert world.css_has_class(selector, "is-active")
    assert len(world.css_find(VIDEO_MENUS["language"] + " li.is-active")) == 1

    # Make sure that all ajax requests that affects the display of captions are finished.
    # For example, request to get new translation etc.
    world.wait_for_ajax_complete()
    world.wait_for_visible(".subtitles")
    world.wait_for_present(".video.is-captions-rendered")
示例#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'])
示例#27
0
def lti_is_rendered(_step, rendered_in):
    if rendered_in.strip() == 'iframe':
        world.wait_for_present('iframe')
        assert world.is_css_present('iframe', wait_time=2)
        assert not world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)

        # iframe is visible
        assert world.css_visible('iframe')
        check_lti_iframe_content("This is LTI tool. Success.")

    elif rendered_in.strip() == 'new page':
        assert not world.is_css_present('iframe', wait_time=2)
        assert world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)
        click_and_check_lti_popup()
    else:  # incorrect rendered_in parameter
        assert False
示例#28
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'])
示例#29
0
def select_language(_step, code):
    world.wait_for_visible('.video-controls')
    # Make sure that all ajax requests that affects the language menu are finished.
    # For example, request to get new translation etc.
    world.wait_for_ajax_complete()
    selector = VIDEO_MENUS["language"] + ' li[data-lang-code="{code}"]'.format(
        code=code)

    world.css_find(VIDEO_BUTTONS["CC"])[0].mouse_over()
    world.wait_for_present('.lang.open')
    world.css_click(selector)

    assert world.css_has_class(selector, 'is-active')
    assert len(world.css_find(VIDEO_MENUS["language"] + ' li.is-active')) == 1

    # Make sure that all ajax requests that affects the display of captions are finished.
    # For example, request to get new translation etc.
    world.wait_for_ajax_complete()
    world.wait_for_visible('.subtitles')
    world.wait_for_present('.video.is-captions-rendered')
示例#30
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'])
示例#31
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'])
示例#32
0
def check_text_in_the_captions(_step, text):
    world.wait_for_present('.video.is-captions-rendered')
    world.wait_for(lambda _: world.css_text('.subtitles'), timeout=30)
    actual_text = world.css_text('.subtitles')
    assert (text in actual_text)
示例#33
0
def click_on_the_caption(_step, index, expected_time):
    world.wait_for_present('.video.is-captions-rendered')
    find_caption_line_by_data_index(int(index)).click()
    actual_time = elapsed_time()
    assert int(expected_time) == actual_time
示例#34
0
def check_captions(_step):
    world.wait_for_present('.video.is-captions-rendered')
    for index, video in enumerate(_step.hashes):
        assert (video.get('text') in world.css_text('.subtitles', index=index))
示例#35
0
def check_text_in_the_captions(_step, text):
    world.wait_for_present('.video.is-captions-rendered')
    world.wait_for(lambda _: world.css_text('.subtitles'))
    actual_text = world.css_text('.subtitles')
    assert (text in actual_text)
示例#36
0
def wait_for_video():
    world.wait_for_present('.is-initialized')
    world.wait_for_present('div.vidtime')
    world.wait_for_invisible('.video-wrapper .spinner')
    world.wait_for_ajax_complete()
示例#37
0
def check_text_in_the_captions(_step, text):
    world.wait_for_present(".video.is-captions-rendered")
    world.wait_for(lambda _: world.css_text(".subtitles"), timeout=30)
    actual_text = world.css_text(".subtitles")
    assert text in actual_text
示例#38
0
def wait_for_video():
    world.wait_for_present(".is-initialized")
    world.wait_for_present("div.vidtime")
    world.wait_for_invisible(".video-wrapper .spinner")
    world.wait_for_ajax_complete()
示例#39
0
def check_captions(_step):
    world.wait_for_present('.video.is-captions-rendered')
    for index, video in enumerate(_step.hashes):
        assert (video.get('text') in world.css_text('.subtitles', index=index))
示例#40
0
def check_captions(_step):
    world.wait_for_present(".video.is-captions-rendered")
    for index, video in enumerate(_step.hashes):
        assert video.get("text") in world.css_text(".subtitles", index=index)
示例#41
0
def click_on_the_caption(_step, index, expected_time):
    world.wait_for_present('.video.is-captions-rendered')
    find_caption_line_by_data_index(int(index)).click()
    actual_time = elapsed_time()
    assert int(expected_time) == actual_time
示例#42
0
def at_the_payment_page(step):
    world.wait_for_present('input[name=transactionSignature]')
示例#43
0
def at_the_payment_page(step):
    world.wait_for_present('input[name=transactionSignature]')
示例#44
0
def click_on_the_caption(_step, index):
    world.wait_for_present('.video.is-captions-rendered')
    world.wait_for(lambda _: world.css_text('.subtitles'), timeout=30)
    find_caption_line_by_data_index(int(index.strip()))._element.send_keys(
        Keys.ENTER)
示例#45
0
def focus_on_caption_line(_step, index):
    world.wait_for_present(".video.is-captions-rendered")
    world.wait_for(lambda _: world.css_text(".subtitles"), timeout=30)
    find_caption_line_by_data_index(int(index.strip()))._element.send_keys(Keys.TAB)
示例#46
0
def wait_for_video():
    world.wait_for_present('.is-initialized')
    world.wait_for_present('div.vidtime')
    world.wait_for_invisible('.video-wrapper .spinner')
    world.wait_for_ajax_complete()
示例#47
0
def click_on_the_caption(_step, index):
    world.wait_for_present('.video.is-captions-rendered')
    world.wait_for(lambda _: world.css_text('.subtitles'), timeout=30)
    find_caption_line_by_data_index(int(index.strip()))._element.send_keys(Keys.ENTER)