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()
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)
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 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 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))
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)
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)
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()
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
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)
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])
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))
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)
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))
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)
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))
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)
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)
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)
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." )
def i_see_new_section_link(step): link_css = ".outline .button-new" assert world.css_has_text(link_css, "New Section")
def i_am_on_tab(step, tab_name): header_css = "div.inner-wrapper h1" assert world.css_has_text(header_css, tab_name)
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)
def i_am_on_tab(step, tab_name): header_css = 'div.inner-wrapper h1' assert world.css_has_text(header_css, tab_name)
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()])
def i_see_the_course_in_my_courses(step): course_css = 'span.class-name' assert world.css_has_text(course_css, 'Robot Super Course')
def i_see_new_section_link(step): link_css = '.outline .button-new' assert world.css_has_text(link_css, 'New Section')
def i_see_new_section_link(step): link_css = 'a.new-courseware-section-button' assert world.css_has_text(link_css, 'New Section')
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')
def see_my_section_on_the_courseware_page(name): section_css = 'span.section-name-span' assert world.css_has_text(section_css, name)
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)
def check_video_speed(_step, player_id, speed): speed_css = '.speeds .value' assert world.css_has_text(speed_css, '{0}x'.format(speed))
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)
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))
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)
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.')
def i_can_see_message(_step, msg): msg = json.dumps(msg) # escape quotes world.css_has_text("h2.title", msg)
def i_see_error_message(_step, error): world.wait(DELAY) assert world.css_has_text(SELECTORS['error_bar'], ERROR_MESSAGES[error.strip()])
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)
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_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.", )
def i_see_error_message(_step, error): assert world.css_has_text(SELECTORS['error_bar'], ERROR_MESSAGES[error])