Exemple #1
0
def i_see_button(_step, not_see, button_type):
    button = button_type.strip()

    if not_see.strip():
        assert world.is_css_not_present(TRANSCRIPTS_BUTTONS[button][0])
    else:
        assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0], TRANSCRIPTS_BUTTONS[button][1])
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()
Exemple #3
0
def see_score(_step, score):
    # The problem progress is changed by
    # cms/static/xmodule_js/src/capa/display.js
    # so give it some time to render on the page.
    score_css = 'div.problem-progress'
    expected_text = '({})'.format(score)
    world.wait_for(lambda _: world.css_has_text(score_css, expected_text))
def test_i_receive_a_warning_about_course_start_date(step):
    assert_true(world.css_has_text('.message-error',
                'The course must have an assigned start date.'))
    assert_true('error' in world.css_find(
        COURSE_START_DATE_CSS).first._element.get_attribute('class'))
    assert_true('error' in world.css_find(
        COURSE_START_TIME_CSS).first._element.get_attribute('class'))
def wait_for_problem(display_name):
    """
    Wait for the problem with `display_name` to appear on the page.
    """
    wait_func = lambda _: world.css_has_text(
        'h2.problem-header', display_name, strip=True
    )
    world.wait_for(wait_func)
Exemple #6
0
def test_i_receive_a_warning_about_course_start_date(step):
    assert_true(
        world.css_has_text('.message-error',
                           'The course must have an assigned start date.'))
    assert_true('error' in world.css_find(
        COURSE_START_DATE_CSS).first._element.get_attribute('class'))
    assert_true('error' in world.css_find(
        COURSE_START_TIME_CSS).first._element.get_attribute('class'))
Exemple #7
0
def select_transcript_format(_step, format):
    button_selector = '.video-tracks .a11y-menu-button'
    menu_selector = VIDEO_MENUS['download_transcript']

    button = world.css_find(button_selector).first
    button.mouse_over()
    assert world.css_has_text(button_selector, '...', strip=True)

    menu_items = world.css_find(menu_selector + ' a')
    for item in menu_items:
        if item['data-value'] == format:
            item.click()
            world.wait_for_ajax_complete()
            break

    assert world.css_find(menu_selector + ' .active a')[0]['data-value'] == format
    assert world.css_has_text(button_selector, '.' + format, strip=True)
Exemple #8
0
def see_elem_text(_step, elem, text):
    selector_map = {
        'progress': '.problem-progress',
        'feedback': '.problem-feedback',
        'module title': '.problem-header'
    }
    assert_in(elem, selector_map)
    assert_true(world.css_has_text(selector_map[elem], text))
Exemple #9
0
def i_see_button(_step, not_see, button_type):
    button = button_type.strip()

    if not_see.strip():
        assert world.is_css_not_present(TRANSCRIPTS_BUTTONS[button][0])
    else:
        assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0],
                                  TRANSCRIPTS_BUTTONS[button][1])
Exemple #10
0
def select_transcript_format(_step, format):
    button_selector = '.video-tracks .a11y-menu-button'
    menu_selector = VIDEO_MENUS['download_transcript']

    button = world.css_find(button_selector).first
    button.mouse_over()
    assert world.css_has_text(button_selector, '...', strip=True)

    menu_items = world.css_find(menu_selector + ' a')
    for item in menu_items:
        if item['data-value'] == format:
            item.click()
            world.wait_for_ajax_complete()
            break

    assert world.css_find(menu_selector +
                          ' .active a')[0]['data-value'] == format
    assert world.css_has_text(button_selector, '.' + format, strip=True)
def wait_for_problem(display_name):
    """
    Wait for the problem with `display_name` to appear on the page.
    """
    # Wait for the problem to reload
    world.wait_for_ajax_complete()

    wait_func = lambda _: world.css_has_text(".problem-header", display_name, strip=True)
    world.wait_for(wait_func)
Exemple #12
0
def i_see_button_with_custom_text(_step, not_see, button_type, custom_text, index):
    button = button_type.strip()
    custom_text = custom_text.strip()
    index = int(index.strip()) - 1

    if not_see.strip():
        assert world.is_css_not_present(TRANSCRIPTS_BUTTONS[button][0])
    else:
        assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0], TRANSCRIPTS_BUTTONS[button][1].format(custom_text), index)
Exemple #13
0
def i_see_button_with_custom_text(_step, not_see, button_type, custom_text, index):
    button = button_type.strip()
    custom_text = custom_text.strip()
    index = int(index.strip()) - 1

    if not_see.strip():
        assert world.is_css_not_present(TRANSCRIPTS_BUTTONS[button][0])
    else:
        assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0], TRANSCRIPTS_BUTTONS[button][1].format(custom_text), index)
Exemple #14
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()
Exemple #15
0
def i_can_download_transcript(_step, format, text):
    assert world.css_has_text(".video-tracks .a11y-menu-button", "." + format, strip=True)

    formats = {"srt": "application/x-subrip", "txt": "text/plain"}

    url = world.css_find(VIDEO_BUTTONS["download_transcript"])[0]["href"]
    request = RequestHandlerWithSessionId()
    assert request.get(url).is_success()
    assert request.check_header("content-type", formats[format])
    assert text.encode("utf-8") in request.content
Exemple #16
0
def foo_is_shown_in_the_bar_filter_dropdown(step, dd_value, dd_name):

    # the only 2 filters on the page are subject and school
    assert_in(dd_name, ['subject', 'school'])

    dd_css = 'select#edit-{dd_name}.form-select'.format(dd_name=dd_name)
    selected_css = "option[selected='selected']"
    full_css = '{dd} {selected}'.format(dd=dd_css, selected=selected_css)

    assert world.css_has_text(full_css, dd_value)
Exemple #17
0
def i_see_button(_step, not_see, button_type):
    world.wait(DELAY)
    world.wait_for_ajax_complete()

    button = button_type.strip()

    if not_see.strip():
        assert world.is_css_not_present(TRANSCRIPTS_BUTTONS[button][0])
    else:
        assert world.css_has_text(TRANSCRIPTS_BUTTONS[button][0], TRANSCRIPTS_BUTTONS[button][1])
Exemple #18
0
def see_elem_text(_step, elem, text):
    selector_map = {
        "progress": ".problem-progress",
        "feedback": ".problem-feedback",
        "module title": ".problem-header",
        "button": ".link_lti_new_window",
        "description": ".lti-description",
    }
    assert_in(elem, selector_map)
    assert_true(world.css_has_text(selector_map[elem], text))
Exemple #19
0
def wait_for_problem(display_name):
    """
    Wait for the problem with `display_name` to appear on the page.
    """
    # Wait for the problem to reload
    world.wait_for_ajax_complete()

    wait_func = lambda _: world.css_has_text(
        'h2.problem-header', display_name, strip=True)
    world.wait_for(wait_func)
Exemple #20
0
def see_elem_text(_step, elem, text):
    selector_map = {
        'progress': '.problem-progress',
        'feedback': '.problem-feedback',
        'module title': '.problem-header',
        'button': '.link_lti_new_window',
        'description': '.lti-description'
    }
    assert_in(elem, selector_map)
    assert_true(world.css_has_text(selector_map[elem], text))
Exemple #21
0
def see_elem_text(_step, elem, text):
    selector_map = {
        'progress': '.problem-progress',
        'feedback': '.problem-feedback',
        'module title': '.problem-header',
        'button': '.link_lti_new_window',
        'description': '.lti-description'
    }
    assert_in(elem, selector_map)
    assert_true(world.css_has_text(selector_map[elem], text))
Exemple #22
0
def see_value_in_the_gradebook(_step, label, text):
    TABLE_SELECTOR = '.grade-table'
    index = 0
    table_headers = world.css_find('{0} thead th'.format(TABLE_SELECTOR))

    for i, element in enumerate(table_headers):
        if element.text.strip() == label:
            index = i
            break;

    assert world.css_has_text('{0} tbody td'.format(TABLE_SELECTOR), text, index=index)
Exemple #23
0
def see_value_in_the_gradebook(_step, label, text):
    table_selector = '.grade-table'
    index = 0
    table_headers = world.css_find('{0} thead th'.format(table_selector))

    for i, element in enumerate(table_headers):
        if element.text.strip() == label:
            index = i
            break

    assert_true(world.css_has_text('{0} tbody td'.format(table_selector), text, index=index))
Exemple #24
0
def see_value_in_the_gradebook(_step, label, text):
    table_selector = '.grade-table'
    index = 0
    table_headers = world.css_find('{0} thead th'.format(table_selector))

    for i, element in enumerate(table_headers):
        if element.text.strip() == label:
            index = i
            break

    assert_true(world.css_has_text('{0} tbody td'.format(table_selector), text, index=index))
Exemple #25
0
def see_value_in_the_gradebook(_step, label, text):
    TABLE_SELECTOR = '.grade-table'
    index = 0
    table_headers = world.css_find('{0} thead th'.format(TABLE_SELECTOR))

    for i, element in enumerate(table_headers):
        if element.text.strip() == label:
            index = i
            break

    assert world.css_has_text('{0} tbody td'.format(TABLE_SELECTOR),
                              text,
                              index=index)
Exemple #26
0
def i_can_download_transcript(_step, format, text):
    assert world.css_has_text('.video-tracks .a11y-menu-button', '.' + format, strip=True)

    formats = {
        'srt': 'application/x-subrip',
        'txt': 'text/plain',
    }

    url = world.css_find(VIDEO_BUTTONS['download_transcript'])[0]['href']
    request = RequestHandlerWithSessionId()
    assert request.get(url).is_success()
    assert request.check_header('content-type', formats[format])
    assert (text.encode('utf-8') in request.content)
Exemple #27
0
def i_can_download_transcript(_step, format, text):
    assert world.css_has_text('.video-tracks .a11y-menu-button', '.' + format, strip=True)

    formats = {
        'srt': 'application/x-subrip',
        'txt': 'text/plain',
    }

    url = world.css_find(VIDEO_BUTTONS['download_transcript'])[0]['href']
    request = RequestHandlerWithSessionId()
    assert request.get(url).is_success()
    assert request.check_header('content-type', formats[format])
    assert (text.encode('utf-8') in request.content)
Exemple #28
0
def select_transcript_format(_step, format):
    button_selector = '.video-tracks .a11y-menu-button'
    menu_selector = VIDEO_MENUS['download_transcript']

    button = world.css_find(button_selector).first

    height = button._element.location_once_scrolled_into_view['y']
    world.browser.driver.execute_script("window.scrollTo(0, {});".format(height))

    button.mouse_over()
    assert world.css_has_text(button_selector, '...', strip=True)

    menu_items = world.css_find(menu_selector + ' a')
    for item in menu_items:
        if item['data-value'] == format:
            item.click()
            world.wait_for_ajax_complete()
            break

    world.browser.driver.execute_script("window.scrollTo(0, 0);")

    assert world.css_find(menu_selector + ' .active a')[0]['data-value'] == format
    assert world.css_has_text(button_selector, '.' + format, strip=True)
Exemple #29
0
def select_transcript_format(_step, format):
    button_selector = '.video-tracks .a11y-menu-button'
    menu_selector = VIDEO_MENUS['download_transcript']

    button = world.css_find(button_selector).first

    height = button._element.location_once_scrolled_into_view['y']
    world.browser.driver.execute_script("window.scrollTo(0, {});".format(height))

    button.mouse_over()
    assert world.css_has_text(button_selector, '...', strip=True)

    menu_items = world.css_find(menu_selector + ' a')
    for item in menu_items:
        if item['data-value'] == format:
            item.click()
            world.wait_for_ajax_complete()
            break

    world.browser.driver.execute_script("window.scrollTo(0, 0);")

    assert world.css_find(menu_selector + ' .active a')[0]['data-value'] == format
    assert world.css_has_text(button_selector, '.' + format, strip=True)
Exemple #30
0
def when_i_send_an_email(recipient):

    # Check that the recipient is valid
    assert_in(
        recipient, SEND_TO_OPTIONS,
        msg="Invalid recipient: {}".format(recipient)
    )

    # Because we flush the database before each run,
    # we need to ensure that the email template fixture
    # is re-loaded into the database
    call_command('loaddata', 'course_email_template.json')

    # Go to the email section of the instructor dash
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('div.beta-button-wrapper>a')
    world.css_click('a[data-section="send_email"]')

    # Select the recipient
    world.select_option('send_to', SEND_TO_OPTIONS[recipient])

    # Enter subject and message
    world.css_fill('input#id_subject', 'Hello')

    with world.browser.get_iframe('mce_0_ifr') as iframe:
        editor = iframe.find_by_id('tinymce')[0]
        editor.fill('test message')

    # Click send
    world.css_click('input[name="send"]')

    # Expect to see a message that the email was sent
    expected_msg = "Your email was successfully queued for sending."
    assert_true(
        world.css_has_text('div.request-response', expected_msg, '#request-response', allow_blank=False),
        msg="Could not find email success message."
    )
Exemple #31
0
def i_see_new_section_link(step):
    link_css = ".outline .button-new"
    assert world.css_has_text(link_css, "New Section")
Exemple #32
0
def i_am_on_tab(step, tab_name):
    header_css = "div.inner-wrapper h1"
    assert world.css_has_text(header_css, tab_name)
Exemple #33
0
def i_see_the_course_in_studio_home(step):
    course_css = "h3.class-title"
    assert world.css_has_text(course_css, world.scenario_dict["COURSE"].display_name)
Exemple #34
0
def i_am_on_tab(step, tab_name):
    header_css = 'div.inner-wrapper h1'
    assert world.css_has_text(header_css, tab_name)
Exemple #35
0
def i_see_status_message(_step, status):
    world.wait(DELAY)
    world.wait_for_ajax_complete()

    assert world.css_has_text(SELECTORS['status_bar'], STATUSES[status.strip()])
Exemple #36
0
def i_see_the_course_in_my_courses(step):
    course_css = 'span.class-name'
    assert world.css_has_text(course_css, 'Robot Super Course')
Exemple #37
0
def i_see_new_section_link(step):
    link_css = '.outline .button-new'
    assert world.css_has_text(link_css, 'New Section')
Exemple #38
0
def i_see_new_section_link(step):
    link_css = 'a.new-courseware-section-button'
    assert world.css_has_text(link_css, 'New Section')
Exemple #39
0
def i_should_see_an_email_verification_prompt(step):
    world.css_has_text('h1.page-header', u'Studio Home')
    world.css_has_text('div.msg h3.title',
                       u'We need to verify your email address')
Exemple #40
0
def see_my_section_on_the_courseware_page(name):
    section_css = 'span.section-name-span'
    assert world.css_has_text(section_css, name)
Exemple #41
0
def error_message_has_correct_text(_step):
    selector = '.video .video-player h3'
    text = _('ERROR: No playable video sources found!')
    assert world.css_has_text(selector, text)
Exemple #42
0
def check_video_speed(_step, player_id, speed):
    speed_css = '.speeds .value'
    assert world.css_has_text(speed_css, '{0}x'.format(speed))
Exemple #43
0
def press_the_button_with_label(_step, buttonname):
    button_css = 'button span.show-label'
    elem = world.css_find(button_css).first
    world.css_has_text(button_css, elem)
    world.css_click(button_css)
Exemple #44
0
def show_hide_label_is(_step, label_name):
    # The label text is changed by static/xmodule_js/src/capa/display.js
    # so give it some time to change on the page.
    label_css = 'button.show span.show-label'
    world.wait_for(lambda _: world.css_has_text(label_css, label_name))
Exemple #45
0
def check_video_speed(_step, player_id, speed):
    speed_css = '.speeds .value'
    assert world.css_has_text(speed_css, '{0}x'.format(speed))
Exemple #46
0
def see_subsection_name(name):
    css = 'span.subsection-name'
    assert world.is_css_present(css)
    css = 'span.subsection-name-value'
    assert world.css_has_text(css, name)
Exemple #47
0
def show_hide_label_is(_step, label_name):
    # The label text is changed by static/xmodule_js/src/capa/display.js
    # so give it some time to change on the page.
    label_css = 'button.show span.show-label'
    world.wait_for(lambda _: world.css_has_text(label_css, label_name))
Exemple #48
0
def press_the_button_with_label(_step, buttonname):
    button_css = 'button span.show-label'
    elem = world.css_find(button_css).first
    world.css_has_text(button_css, elem)
    world.css_click(button_css)
Exemple #49
0
def i_see_error_about_length(step):
    assert world.css_has_text('#course_creation_error', 'The combined length of the organization, course number, and course run fields cannot be more than 65 characters.')
Exemple #50
0
def see_subsection_name(name):
    css = 'span.subsection-name'
    assert world.is_css_present(css)
    css = 'span.subsection-name-value'
    assert world.css_has_text(css, name)
Exemple #51
0
def i_can_see_message(_step, msg):
    msg = json.dumps(msg)  # escape quotes
    world.css_has_text("h2.title", msg)
Exemple #52
0
def i_see_error_message(_step, error):
    world.wait(DELAY)

    assert world.css_has_text(SELECTORS['error_bar'], ERROR_MESSAGES[error.strip()])
Exemple #53
0
def i_see_the_course_in_my_courses(step):
    course_css = 'h3.class-title'
    assert world.css_has_text(course_css, world.scenario_dict['COURSE'].display_name)
Exemple #54
0
def error_message_has_correct_text(_step):
    selector = '.video .video-player h3'
    text = _('ERROR: No playable video sources found!')
    assert world.css_has_text(selector, text)
Exemple #55
0
def success_upload_file(filename):
    upload_file(filename, sub_path="uploads/")
    world.css_has_text('#upload_confirm', 'Success!')
    world.is_css_not_present('.wrapper-modal-window-assetupload', wait_time=30)
def i_can_see_message(_step, msg):
    msg = json.dumps(msg)     # escape quotes
    world.css_has_text("h2.title", msg)
Exemple #57
0
def i_see_error_about_length(step):
    assert world.css_has_text(
        "#course_creation_error",
        "The combined length of the organization, course number, "
        "and course run fields cannot be more than 65 characters.",
    )
Exemple #58
0
def i_see_error_message(_step, error):
    assert world.css_has_text(SELECTORS['error_bar'], ERROR_MESSAGES[error])
Exemple #59
0
def success_upload_file(filename):
    upload_file(filename, sub_path="uploads/")
    world.css_has_text('#upload_confirm', 'Success!')
    world.is_css_not_present('.wrapper-modal-window-assetupload', wait_time=30)