Esempio n. 1
0
    def setup_problem_attempts(self, step, not_attempted=None):
        r'that the conditioned problem has (?P<not_attempted>not )?been attempted$'
        visit_scenario_item('CONDITION_SOURCE')

        if not_attempted is None:
            answer_problem(self.COURSE_NUM, 'string', True)
            world.css_click("button.check")
Esempio n. 2
0
def navigate_to_an_openended_question_as_staff(step):
    world.register_by_course_id('MITx/3.091x/2012_Fall', True)
    world.log_in(email='*****@*****.**', password='******')
    problem = '/courses/MITx/3.091x/2012_Fall/courseware/Week_10/Polymer_Synthesis/'
    world.browser.visit(django_url(problem))
    tab_css = 'ol#sequence-list > li > a[data-element="5"]'
    world.css_click(tab_css)
Esempio n. 3
0
def i_click_the_collapse_expand_all_span(step, text):
    if text == "Collapse":
        span_locator = ".button-toggle-expand-collapse .collapse-all .label"
    elif text == "Expand":
        span_locator = ".button-toggle-expand-collapse .expand-all .label"
    assert_true(world.browser.is_element_present_by_css(span_locator))
    world.css_click(span_locator)
Esempio n. 4
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)
Esempio n. 5
0
def add_subsection(name='Subsection One'):
    css = 'a.new-subsection-item'
    world.css_click(css)
    name_css = 'input.new-subsection-name-input'
    save_css = 'input.new-subsection-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
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()
def _click_advanced():
    css = 'ul.problem-type-tabs a[href="#tab2"]'
    world.css_click(css)

    # Wait for the advanced tab items to be displayed
    tab2_css = 'div.ui-tabs-panel#tab2'
    world.wait_for_visible(tab2_css)
Esempio n. 8
0
def select_the_audit_track(step):
    create_cert_course()
    register()
    btn_css = 'input[value="Select Audit"]'
    world.wait(1)  # TODO remove this after troubleshooting JZ
    world.css_find(btn_css)
    world.css_click(btn_css)
Esempio n. 9
0
def select_verified_track_upgrade(step):
    select_contribution(32)
    world.wait_for_ajax_complete()
    btn_css = 'input[value="Upgrade Your Registration"]'
    world.css_click(btn_css)
    # TODO: might want to change this depending on the changes for upgrade
    assert world.is_css_present('section.progress')
Esempio n. 10
0
def submit_partial_problem_type(step, submission_type):
    type_css = '#feedback_link_{}'.format(submission_type)
    world.css_click(type_css)
    fill_field('subject', 'Test Issue')
    fill_field('details', 'I am having a problem')
    submit_css = 'div.submit'
    world.css_click(submit_css)
Esempio n. 11
0
def register():
    url = 'courses/{org}/{number}/{name}/about'.format(
        org='edx', number='999', name='Certificates')
    world.browser.visit(django_url(url))

    world.css_click('section.intro a.register')
    assert world.is_css_present('section.wrapper h3.title')
Esempio n. 12
0
def select_the_verified_track(step):
    create_cert_course()
    register()
    select_contribution(32)
    btn_css = 'input[value="Select Certificate"]'
    world.css_click(btn_css)
    assert world.is_css_present('section.progress')
Esempio n. 13
0
def test_i_select_schedule_and_details(step):
    world.click_course_settings()
    link_css = "li.nav-course-settings-schedule a"
    world.css_click(link_css)
    world.wait_for_requirejs(
        ["jquery", "js/models/course", "js/models/settings/course_details", "js/views/settings/main"]
    )
def create_component_instance(step, category, component_type=None, is_advanced=False):
    """
    Create a new component in a Unit.

    Parameters
    ----------
    category: component type (discussion, html, problem, video)
    component_type: for components with multiple templates, the link text in the menu
    is_advanced: for problems, is the desired component under the advanced menu?
    """
    assert_in(category, ["problem", "html", "video", "discussion"])

    component_button_css = "span.large-{}-icon".format(category.lower())
    if category == "problem":
        module_css = "section.xmodule_CapaModule"
    else:
        module_css = "section.xmodule_{}Module".format(category.title())

    # Count how many of that module is on the page. Later we will
    # assert that one more was added.
    # We need to use world.browser.find_by_css instead of world.css_find
    # because it's ok if there are currently zero of them.
    module_count_before = len(world.browser.find_by_css(module_css))

    # Disable the jquery animation for the transition to the menus.
    world.disable_jquery_animations()
    world.css_click(component_button_css)

    if category in ("problem", "html"):
        world.wait_for_invisible(component_button_css)
        click_component_from_menu(category, component_type, is_advanced)

    expected_count = module_count_before + 1
    world.wait_for(lambda _: len(world.css_find(module_css)) == expected_count, timeout=20)
Esempio n. 15
0
def click_on_section(step, section):
    section_css = 'h3[tabindex="-1"]'
    world.css_click(section_css)

    subid = "ui-accordion-accordion-panel-{}".format(str(int(section) - 1))
    subsection_css = "ul.ui-accordion-content-active[id='{}'] > li > a".format(subid)
    world.css_click(subsection_css)
Esempio n. 16
0
def other_delete_self(_step):
    to_delete_css = '.user-item .item-actions a.remove-user[data-id="{email}"]'.format(
        email="*****@*****.**")
    world.css_click(to_delete_css)
    # confirm prompt
    world.wait(.5)
    world.css_click(".wrapper-prompt-warning .action-primary")
def save_component_and_reopen(step):
    world.css_click("a.save-button")
    world.wait_for_ajax_complete()
    # We have a known issue that modifications are still shown within the edit window after cancel (though)
    # they are not persisted. Refresh the browser to make sure the changes WERE persisted after Save.
    reload_the_page(step)
    edit_component_and_select_settings()
Esempio n. 18
0
    def setup_problem_attempts(self, step, not_attempted=None):
        r"that the conditioned problem has (?P<not_attempted>not )?been attempted$"
        visit_scenario_item("CONDITION_SOURCE")

        if not_attempted is None:
            answer_problem(self.COURSE_NUM, "string", True)
            world.css_click("input.check")
Esempio n. 19
0
def i_register_to_audit_the_course(_step):
    url = django_url('courses/%s/about' % world.scenario_dict['COURSE'].id.to_deprecated_string())
    world.browser.visit(url)
    world.css_click('section.intro a.register')
    audit_button = world.browser.find_by_name("audit_mode")
    audit_button.click()
    assert world.is_css_present('section.container.dashboard')
Esempio n. 20
0
def i_verify_all_the_content_of_each_course(step):
    all_possible_courses = get_courses()
    logger.debug('Courses found:')
    for c in all_possible_courses:
        logger.debug(c.id)
    ids = [c.id for c in all_possible_courses]

    # Get a list of all the registered courses
    registered_courses = world.browser.find_by_css('article.my-course')
    if len(all_possible_courses) < len(registered_courses):
        assert False, "user is registered for more courses than are uniquely posssible"
    else:
        pass

    for test_course in registered_courses:
        test_course.css_click('a')
        check_for_errors()

        # Get the course. E.g. 'MITx/6.002x/2012_Fall'
        current_course = sub('/info', '', sub('.*/courses/', '', world.browser.url))
        validate_course(current_course, ids)

        world.click_link('Courseware')
        assert world.is_css_present('accordion')
        check_for_errors()
        browse_course(current_course)

        # clicking the user link gets you back to the user's home page
        world.css_click('.user-link')
        check_for_errors()
Esempio n. 21
0
def press_the_notification_button(_step, name):
    # TODO: fix up this code. Selenium is not dealing well with css transforms,
    # as it thinks that the notification and the buttons are always visible

    # First wait for the notification to pop up
    notification_css = 'div#page-notification div.wrapper-notification'
    world.wait_for_visible(notification_css)

    # You would think that the above would have worked, but it doesn't.
    # Brute force wait for now.
    world.wait(.5)

    # Now make sure the button is there
    btn_css = 'div#page-notification a.action-%s' % name.lower()
    world.wait_for_visible(btn_css)

    # You would think that the above would have worked, but it doesn't.
    # Brute force wait for now.
    world.wait(.5)

    if world.is_firefox():
        # This is done to explicitly make the changes save on firefox.
        # It will remove focus from the previously focused element
        world.trigger_event(btn_css, event='focus')
        world.browser.execute_script("$('{}').click()".format(btn_css))
    else:
        world.css_click(btn_css)
def create_component_instance(step, category, component_type=None, is_advanced=False):
    """
    Create a new component in a Unit.

    Parameters
    ----------
    category: component type (discussion, html, problem, video)
    component_type: for components with multiple templates, the link text in the menu
    is_advanced: for html and problem, is the desired component under the
                 advanced menu
    """
    assert_in(category, ['problem', 'html', 'video', 'discussion'])

    component_button_css = '.large-{}-icon'.format(category.lower())
    world.css_click(component_button_css)

    if category in ('problem', 'html'):
        world.wait_for_invisible(component_button_css)
        click_component_from_menu(category, component_type, is_advanced)

    if category == 'problem':
        expected_css = 'section.xmodule_CapaModule'
    else:
        expected_css = 'section.xmodule_{}Module'.format(category.title())

    assert_true(world.is_css_present(expected_css))
Esempio n. 23
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)
Esempio n. 24
0
def add_subsection(name="Subsection One"):
    css = "a.new-subsection-item"
    world.css_click(css)
    name_css = "input.new-subsection-name-input"
    save_css = "input.new-subsection-name-save"
    world.css_fill(name_css, name)
    world.css_click(save_css)
def click_new_component_button(step, component_button_css):
    step.given('I have clicked the new unit button')
    world.wait_for_requirejs(
        ["jquery", "js/models/course", "coffee/src/models/module",
         "coffee/src/views/unit", "jquery.ui", "domReady!"]
    )
    world.css_click(component_button_css)
Esempio n. 26
0
def i_register_for_the_course(_step, course):
    cleaned_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_')
    url = django_url('courses/%s/%s/%s/about' % (world.scenario_dict['COURSE'].org, course, cleaned_name))
    world.browser.visit(url)
    world.css_click('section.intro a.register')

    assert world.is_css_present('section.container.dashboard')
Esempio n. 27
0
def upload_file(filename):
    file_css = '.upload-dialog input[type=file]'
    upload = world.css_find(file_css).first
    path = os.path.join(TEST_ROOT, filename)
    upload._element.send_keys(os.path.abspath(path))
    button_css = '.upload-dialog .action-upload'
    world.css_click(button_css)
def create_component_instance(step, category, component_type=None, is_advanced=False):
    """
    Create a new component in a Unit.

    Parameters
    ----------
    category: component type (discussion, html, problem, video)
    component_type: for components with multiple templates, the link text in the menu
    is_advanced: for html and problem, is the desired component under the
                 advanced menu
    """
    assert_in(category, ['problem', 'html', 'video', 'discussion'])

    component_button_css = 'span.large-{}-icon'.format(category.lower())
    if category == 'problem':
        module_css = 'section.xmodule_CapaModule'
    else:
        module_css = 'section.xmodule_{}Module'.format(category.title())

    # Count how many of that module is on the page. Later we will
    # assert that one more was added.
    # We need to use world.browser.find_by_css instead of world.css_find
    # because it's ok if there are currently zero of them.
    module_count_before =  len(world.browser.find_by_css(module_css))

    world.css_click(component_button_css)

    if category in ('problem', 'html'):
        world.wait_for_invisible(component_button_css)
        click_component_from_menu(category, component_type, is_advanced)

    world.wait_for(lambda _: _is_expected_element_count(module_css,
        module_count_before + 1))
Esempio n. 29
0
def when_i_navigate_to_a_section(step):
    # Open the 2nd section
    world.css_click(css_selector='div.chapter', index=1)
    subsection_css = 'a[href*="Test_Subsection_2/"]'

    # Click on the subsection to see the content
    world.css_click(subsection_css)
Esempio n. 30
0
def create_latex_problem(step):
    world.click_new_component_button(step, '.large-problem-icon')
    # Go to advanced tab (waiting for the tab to be visible)
    world.css_find('#ui-id-2')
    world.css_click('#ui-id-2')
    world.click_component_from_menu(
        "i4x://edx/templates/problem/Problem_Written_in_LaTeX", '.xmodule_CapaModule')
Esempio n. 31
0
def add_assignment_type(step, new_name):
    add_button_css = '.add-grading-data'
    world.css_click(add_button_css)
    name_id = '#course-grading-assignment-name'
    new_assignment = world.css_find(name_id)[-1]
    new_assignment._element.send_keys(new_name)
Esempio n. 32
0
def press_the_save_button(_step):
    button_css = '.input_cloud_section input.save'
    elem = world.css_find(button_css).first
    world.css_has_text(button_css, elem)
    world.css_click(button_css)
Esempio n. 33
0
def go_to_static(_step):
    menu_css = 'li.nav-course-courseware'
    static_css = 'li.nav-course-courseware-pages a'
    world.css_click(menu_css)
    world.css_click(static_css)
Esempio n. 34
0
def click_edit_delete(_step, edit_delete, page):
    button_css = 'a.%s-button' % edit_delete
    index = get_index(page)
    assert index != -1
    world.css_click(button_css, index=index)
Esempio n. 35
0
def add_page(_step):
    button_css = 'a.new-button'
    world.css_click(button_css)
Esempio n. 36
0
def add_grade(step, many):
    grade_css = '.new-grade-button'
    for __ in range(int(many)):
        world.css_click(grade_css)
Esempio n. 37
0
def view_grading_settings(step):
    world.click_course_settings()
    link_css = 'li.nav-course-settings-grading a'
    world.css_click(link_css)
Esempio n. 38
0
def edit_and_save_component(step):
    world.css_click('.edit-button')
    world.css_click('.save-button')
Esempio n. 39
0
def when_i_navigate_to_an_item_in_a_sequence(step):
    sequence_css = 'a[data-element="2"]'
    world.css_click(sequence_css)
Esempio n. 40
0
def delete_assignment_type(step, to_delete):
    delete_css = '.remove-grading-data'
    world.css_click(delete_css, index=get_type_index(to_delete))
Esempio n. 41
0
def click_new_component_button(step, component_button_css):
    step.given('I have clicked the new unit button')

    world.css_click(component_button_css)
Esempio n. 42
0
def delete_one_component(step):
    world.css_click('a.delete-button')
Esempio n. 43
0
def save_component(step):
    world.css_click("a.save-button")
    world.wait_for_ajax_complete()
Esempio n. 44
0
def when_i_navigate_to_a_subsection(step):
    # Click on the 2nd subsection to see the content
    subsection_css = 'a[href*="Test_Subsection_2/"]'
    world.css_click(subsection_css)
Esempio n. 45
0
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')
Esempio n. 46
0
def cancel_component(step):
    world.css_click("a.cancel-button")
    # We have a known issue that modifications are still shown within the edit window after cancel (though)
    # they are not persisted. Refresh the browser to make sure the changes were not persisted.
    reload_the_page(step)
Esempio n. 47
0
def click_edit_or_delete(step, edit_or_delete):
    button_css = 'ul.component-actions a.%s-button' % edit_or_delete
    world.css_click(button_css)
Esempio n. 48
0
def edit_component():
    world.wait_for(lambda _driver: world.css_visible('a.edit-button'))
    world.css_click('a.edit-button')
Esempio n. 49
0
def i_enabled_the_advanced_module(step, module):
    step.given('I have opened a new course section in Studio')
    world.css_click('.nav-course-settings')
    world.css_click('.nav-course-settings-advanced a')
    type_in_codemirror(0, '["%s"]' % module)
    press_the_notification_button(step, 'Save')
Esempio n. 50
0
def i_export_the_course(step):
    world.click_tools()
    link_css = 'li.nav-course-tools-export a'
    world.css_click(link_css)
    world.css_click('a.action-export')
Esempio n. 51
0
def save_textbook(_step):
    submit_css = "form.edit-textbook button[type=submit]"
    world.css_click(submit_css)
Esempio n. 52
0
def select_new_course(_step, whom):
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
Esempio n. 53
0
def click_upload_asset(_step, ordinal):
    index = ["first", "second", "third"].index(ordinal)
    button_css = ".textbook .chapter{i} .action-upload".format(i=index + 1)
    world.css_click(button_css)
Esempio n. 54
0
def add_section():
    world.css_click('.outline .button-new')
    assert_true(world.is_css_present('.outline-section .xblock-field-value'))
Esempio n. 55
0
def click_chapters(_step):
    world.css_click(".textbook a.chapter-toggle")
Esempio n. 56
0
def click_add_chapter(_step):
    button_css = ".textbook .action-add-chapter"
    world.css_click(button_css)
Esempio n. 57
0
def navigate_to_an_item_in_a_sequence(number):
    sequence_css = '#sequence-list a[data-element="{0}"]'.format(number)
    world.css_click(sequence_css)
Esempio n. 58
0
def go_to_uploads(_step):
    world.click_course_content()
    menu_css = 'li.nav-course-courseware-textbooks a'
    world.css_click(menu_css)
Esempio n. 59
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')
Esempio n. 60
0
def change_video_speed(speed):
    world.browser.execute_script("$('.speeds').addClass('is-opened')")
    speed_css = 'li[data-speed="{0}"] a'.format(speed)
    world.wait_for_visible('.speeds')
    world.css_click(speed_css)