示例#1
0
def set_captions_visibility_state(_step, captions_state):
    if captions_state == 'closed':
        if world.css_visible('.subtitles'):
            world.browser.find_by_css('.hide-subtitles').click()
    else:
        if not world.css_visible('.subtitles'):
            world.browser.find_by_css('.hide-subtitles').click()
示例#2
0
def set_captions_visibility_state(_step, captions_state):
    if captions_state == "closed":
        if world.css_visible(".subtitles"):
            world.browser.find_by_css(".hide-subtitles").click()
    else:
        if not world.css_visible(".subtitles"):
            world.browser.find_by_css(".hide-subtitles").click()
示例#3
0
def is_hidden_button(_step, button, state):
    selector = VIDEO_BUTTONS[button]
    if state == "hidden":
        world.wait_for_invisible(selector)
        assert_false(world.css_visible(selector), "Button {0} is invisible, but should be visible".format(button))
    else:
        world.wait_for_visible(selector)
        assert_true(world.css_visible(selector), "Button {0} is visible, but should be invisible".format(button))
示例#4
0
def all_sections_are_collapsed_or_expanded(step, text):
    subsection_locator = "div.subsection-list"
    subsections = world.css_find(subsection_locator)
    for index in range(len(subsections)):
        if text == "collapsed":
            assert_false(world.css_visible(subsection_locator, index=index))
        elif text == "expanded":
            assert_true(world.css_visible(subsection_locator, index=index))
示例#5
0
def i_should_see_a_login_error(step, should_not_see):
    if should_not_see:
        # the login error may be absent or invisible. Check absence first,
        # because css_visible will throw an exception if the element is not present
        if world.is_css_present('div#login_error'):
            assert_false(world.css_visible('div#login_error'))
    else:
        assert_true(world.css_visible('div#login_error'))
示例#6
0
def lti_is_rendered(_step):
    # lti div has class rendered
    assert world.is_css_present('div.lti.rendered')

    # error is hidden
    assert not world.css_visible('.error_message')

    # iframe is visible
    assert world.css_visible('iframe')
    check_lti_ifarme_content("This is LTI tool. Success.")
示例#7
0
def incorrect_lti_is_rendered(_step):
    # lti div has class rendered
    assert world.is_css_present('div.lti.rendered')

    # error is hidden
    assert not world.css_visible('.error_message')

    # iframe is visible
    assert world.css_visible('iframe')
    check_lti_ifarme_content("Wrong LTI signature")
示例#8
0
def i_enter_a_source(_step, link, index):
    index = int(index) - 1

    if index is not 0 and not world.css_visible(SELECTORS["collapse_bar"]):
        world.css_click(SELECTORS["collapse_link"])

        assert world.css_visible(SELECTORS["collapse_bar"])

    world.css_fill(SELECTORS["url_inputs"], link, index)
    world.wait(DELAY)
    world.wait_for_ajax_complete()
示例#9
0
def check_captions_visibility_state(_step, visibility_state, timeout):
    timeout = int(timeout.strip())

    # Captions become invisible by fading out. We must wait by a specified
    # time.
    world.wait(timeout)

    if visibility_state == "visible":
        assert world.css_visible(".subtitles")
    else:
        assert not world.css_visible(".subtitles")
示例#10
0
def lti_is_not_rendered(_step):
    # lti div has no class rendered
    assert world.is_css_not_present('div.lti.rendered')

    # error is shown
    assert world.css_visible('.error_message')

    # iframe is not visible
    assert not world.css_visible('iframe')

    #inside iframe test content is not presented
    with world.browser.get_iframe('ltiLaunchFrame') as iframe:
        # iframe does not contain functions from terrain/ui_helpers.py
        assert iframe.is_element_not_present_by_css('.result', wait_time=5)
def edit_component(index=0):
    # Verify that the "loading" indication has been hidden.
    world.wait_for_loading()
    # Verify that the "edit" button is present.
    world.wait_for(lambda _driver: world.css_visible('a.edit-button'))
    world.css_click('a.edit-button', index)
    world.wait_for_ajax_complete()
示例#12
0
def i_see_status_message(_step, status):
    assert not world.css_visible(SELECTORS['error_bar'])
    assert world.css_has_text(SELECTORS['status_bar'], STATUSES[status])

    DOWNLOAD_BUTTON = TRANSCRIPTS_BUTTONS["download_to_edit"][0]
    if world.is_css_present(DOWNLOAD_BUTTON, wait_time=1) and not world.css_find(DOWNLOAD_BUTTON)[0].has_class('is-disabled'):
        assert _transcripts_are_downloaded()
示例#13
0
def set_show_captions(step, setting):
    # Prevent cookies from overriding course settings
    world.browser.cookies.delete('hide_captions')

    world.css_click('a.edit-button')
    world.wait_for(lambda _driver: world.css_visible('a.save-button'))
    world.browser.select('Show Captions', setting)
    world.css_click('a.save-button')
示例#14
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)

    prompt_confirm_css = 'li.nav-item > a.action-primary'
    world.css_click(prompt_confirm_css, success_condition=lambda: not world.css_visible(prompt_confirm_css))
示例#15
0
def set_subsection_due_date(_step, datestring, timestring):
    if hasattr(timestring, "strip"):
        timestring = timestring.strip()
    if not timestring:
        timestring = "00:00"
    if not world.css_visible("input#due_date"):
        world.css_click(".due-date-input .set-date")
    set_date_and_time("input#due_date", datestring, "input#due_time", timestring)
示例#16
0
def set_show_captions(step, setting):
    # Prevent cookies from overriding course settings
    world.browser.cookies.delete("hide_captions")

    world.css_click("a.edit-button")
    world.wait_for(lambda _driver: world.css_visible("a.save-button"))
    world.click_link_by_text("Advanced")
    world.browser.select("Show Transcript", setting)
    world.css_click("a.save-button")
示例#17
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.")
示例#18
0
def set_show_captions(step, setting):
    # Prevent cookies from overriding course settings
    world.browser.cookies.delete('hide_captions')

    world.css_click('a.edit-button')
    world.wait_for(lambda _driver: world.css_visible('a.save-button'))
    world.click_link_by_text('Advanced')
    world.browser.select('Transcript Display', setting)
    world.css_click('a.save-button')
示例#19
0
def incorrect_lti_is_rendered(_step):
    # lti div has class rendered
    assert world.is_css_present('div.lti.rendered')

    # error is hidden
    assert not world.css_visible('.error_message')

    # iframe is visible
    assert world.css_visible('iframe')

    #inside iframe test content is presented
    with world.browser.get_iframe('ltiLaunchFrame') as iframe:
        # iframe does not contain functions from terrain/ui_helpers.py
        assert iframe.is_element_present_by_css('.result', wait_time=5)
        assert ("Wrong LTI signature" == world.retry_on_exception(
            lambda: iframe.find_by_css('.result')[0].text,
            max_attempts=5
        ))
示例#20
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)
    assert not world.css_visible(SELECTORS["spinner"])
示例#21
0
def do_not_see_or_not_button_video(_step, action, button_type):
    world.wait(DELAY)
    world.wait_for_ajax_complete()
    action = action.strip()
    button = button_type.strip()
    if action == 'do not':
        assert not world.is_css_present(VIDEO_BUTTONS[button])
    elif action == 'can':
        assert world.css_visible(VIDEO_BUTTONS[button])
    else:
        raise ValueError('Parameter `action` should be one of "do not" or "can".')
示例#22
0
def lti_is_not_rendered(_step):
    # lti div has no class rendered
    assert world.is_css_not_present('div.lti.rendered')

    # error is shown
    assert world.css_visible('.error_message')

    # iframe is not visible
    assert not world.css_visible('iframe')

    #inside iframe test content is not presented
    with world.browser.get_iframe('ltiLaunchFrame') as iframe:
        # iframe does not contain functions from terrain/ui_helpers.py
        world.browser.driver.implicitly_wait(1)
        try:
            assert iframe.is_element_not_present_by_css('.result', wait_time=1)
        except:
            raise
        finally:
            world.browser.driver.implicitly_wait(world.IMPLICIT_WAIT)
示例#23
0
    def check_visibility(self, step, visible):
        r'the conditional contents are (?P<visible>\w+)$'
        world.wait_for_ajax_complete()

        assert_in(visible, ('visible', 'hidden'))

        if visible == 'visible':
            world.wait_for_visible('.hidden-contents')
            assert_true(world.css_visible('.hidden-contents'))
        else:
            assert_true(world.is_css_not_present('.hidden-contents'))
示例#24
0
    def check_visibility(self, step, visible):
        r"the conditional contents are (?P<visible>\w+)$"
        world.wait_for_ajax_complete()

        assert_in(visible, ("visible", "hidden"))

        if visible == "visible":
            world.wait_for_visible(".hidden-contents")
            assert_true(world.css_visible(".hidden-contents"))
        else:
            assert_true(world.is_css_not_present(".hidden-contents"))
示例#25
0
def select_language(_step, code):
    _open_menu("language")
    selector = VIDEO_MENUS["language"] + ' li[data-lang-code={code}]'.format(
        code=code
    )

    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()
示例#26
0
    def check_visibility(self, step, visible):
        r'the conditional contents are (?P<visible>\w+)$'
        world.wait_for_ajax_complete()

        assert_in(visible, ('visible', 'hidden'))

        if visible == 'visible':
            world.wait_for_visible('.hidden-contents')
            assert_true(world.css_visible('.hidden-contents'))
        else:
            assert_true(world.is_css_not_present('.hidden-contents'))
            assert_true(world.css_contains_text('.conditional-message', 'must be attempted before this will become visible.'))  # sarina
示例#27
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()
示例#28
0
def css_click_at(css_selector, index=0, x_coord=10, y_coord=10, timeout=5):
    '''
    A method to click at x,y coordinates of the element
    rather than in the center of the element
    '''
    wait_for_clickable(css_selector, timeout=timeout)
    assert_true(
        world.css_visible(css_selector, index=index),
        msg="Element {}[{}] is present but not visible".format(css_selector, index)
    )

    element.action_chains.move_to_element_with_offset(element._element, x_coord, y_coord)
    element.action_chains.click()
    element.action_chains.perform()
def click_component_from_menu(category, boilerplate, expected_css):
    """
    Creates a component from `instance_id`. For components with more
    than one template, clicks on `elem_css` to create the new
    component. Components with only one template are created as soon
    as the user clicks the appropriate button, so we assert that the
    expected component is present.
    """
    if boilerplate:
        elem_css = "a[data-category='{}'][data-boilerplate='{}']".format(category, boilerplate)
    else:
        elem_css = "a[data-category='{}']:not([data-boilerplate])".format(category)
    elements = world.css_find(elem_css)
    assert_equal(len(elements), 1)
    world.wait_for(lambda _driver: world.css_visible(elem_css))
    world.css_click(elem_css, success_condition=lambda: 1 == len(world.css_find(expected_css)))
示例#30
0
def lti_is_rendered(_step, rendered_in):
    if rendered_in.strip() == '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)
        check_lti_popup()
    else:  # incorrent rendered_in parameter
        assert False
def edit_component():
    world.wait_for(lambda _driver: world.css_visible('a.edit-button'))
    world.css_click('a.edit-button')
示例#32
0
def i_see_the_span_with_text(step, text):
    span_locator = '.toggle-button-sections span'
    assert_true(world.is_css_present(span_locator))
    assert_equal(world.css_value(span_locator), text)
    assert_true(world.css_visible(span_locator))
示例#33
0
def confirm_the_prompt(step):
    prompt_css = 'a.button.action-primary'
    world.css_click(
        prompt_css,
        success_condition=lambda: not world.css_visible(prompt_css))
示例#34
0
def i_click_on_edit_icon(step):
    world.edit_component()
    world.wait_for(lambda _driver: world.css_visible('a.visual-tab'))
    world.css_click('a.visual-tab')
def login_dialog_visible(step):
    assert world.css_visible('form#login_form.login_form')
示例#36
0
def see_a_range_slider_with_proper_range(_step):
    world.wait_for_visible(VIDEO_BUTTONS['pause'])
    assert world.css_visible(".slider-range")
示例#37
0
def all_sections_are_collapsed(step):
    subsection_locator = 'div.subsection-list'
    subsections = world.css_find(subsection_locator)
    for index in range(len(subsections)):
        assert_false(world.css_visible(subsection_locator, index=index))
示例#38
0
def error_message_is_shown(_step):
    selector = '.video .video-player h3'
    assert world.css_visible(selector)
示例#39
0
def the_section_release_date_picker_not_visible(_step):
    css = 'div.edit-subsection-publish-settings'
    assert not world.css_visible(css)
def edit_component_and_select_settings():
    world.wait_for(lambda _driver: world.css_visible('a.edit-button'))
    world.css_click('a.edit-button')
    world.css_click('#settings-mode a')
示例#41
0
def check_captions_visibility_state(_step, visibility_state):
    if visibility_state == 'visible':
        assert world.css_visible('.subtitles')
    else:
        assert not world.css_visible('.subtitles')
def i_do_not_see_the_span_with_text(step, text):
    # Note that the span will exist on the page but not be visible
    span_locator = '.toggle-button-sections span'
    assert_true(world.is_css_present(span_locator))
    assert_false(world.css_visible(span_locator))
示例#43
0
def i_do_not_see_error_message(_step):
    assert not world.css_visible(SELECTORS['error_bar'])
示例#44
0
def i_do_not_see_status_message(_step):
    assert not world.css_visible(SELECTORS['status_bar'])