예제 #1
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 asset_chapter(_step, name, ordinal):
    index = ["first", "second", "third"].index(ordinal)
    input_css = ".textbook .chapter{i} input.chapter-asset-path".format(
        i=index + 1)
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
예제 #3
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)
예제 #4
0
파일: pages.py 프로젝트: eliesmr4/myedx
def change_name(step, new_name):
    settings_css = '.settings-button'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    world.save_component()
예제 #5
0
def set_weight(weight):
    index = world.get_setting_entry_index(PROBLEM_WEIGHT)
    world.css_fill('.wrapper-comp-setting .setting-input', weight, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input',
                            index=index,
                            event='blur')
        world.trigger_event('a.save-button', event='focus')
예제 #6
0
def change_name(step, new_name):
    settings_css = '.settings-button'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    world.save_component()
def i_can_modify_the_display_name(step):
    # Verifying that the display name can be a string containing a floating point value
    # (to confirm that we don't throw an error because it is of the wrong type).
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input', '3.4', index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    verify_modified_display_name()
예제 #8
0
def i_can_modify_the_display_name(_step):
    # Verifying that the display name can be a string containing a floating point value
    # (to confirm that we don't throw an error because it is of the wrong type).
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input', '3.4', index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    verify_modified_display_name()
예제 #9
0
def set_the_max_attempts(step, max_attempts_set):
    # on firefox with selenium, the behaviour is different.  eg 2.34 displays as 2.34 and is persisted as 2
    index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS)
    world.css_fill('.wrapper-comp-setting .setting-input', max_attempts_set, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    world.save_component_and_reopen(step)
    value =  int(world.css_value('input.setting-input', index=index))
    assert value >= 0
예제 #10
0
def i_can_modify_the_display_name_with_special_chars(step):
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input',
                   "updated ' \" &",
                   index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input',
                            index=index)
    verify_modified_display_name_with_special_chars()
예제 #11
0
def set_the_max_attempts(step, max_attempts_set):
    # on firefox with selenium, the behaviour is different.  eg 2.34 displays as 2.34 and is persisted as 2
    index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS)
    world.css_fill('.wrapper-comp-setting .setting-input', max_attempts_set, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    world.save_component_and_reopen(step)
    value =  int(world.css_value('input.setting-input', index=index))
    assert value >= 0
예제 #12
0
def change_name(step, new_name):
    settings_css = '#settings-mode a'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = 'a.save-button'
    world.css_click(save_button)
예제 #13
0
def change_name(step, new_name):
    settings_css = '#settings-mode a'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = 'a.save-button'
    world.css_click(save_button)
예제 #14
0
def change_name(_step, new_name):
    settings_css = "#settings-mode a"
    world.css_click(settings_css)
    input_css = "input.setting-input"
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = "a.save-button"
    world.css_click(save_button)
예제 #15
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)
    world.wait(0.5)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + EMAIL_EXTENSION)
    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 add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)
    world.wait(0.5)

    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)
예제 #17
0
def type_in_codemirror(index, text):
    world.css_click("div.CodeMirror-lines", index=index)
    world.browser.execute_script("$('div.CodeMirror.CodeMirror-focused > div').css('overflow', '')")
    g = world.css_find("div.CodeMirror.CodeMirror-focused > div > textarea")
    if world.is_mac():
        g._element.send_keys(Keys.COMMAND + 'a')
    else:
        g._element.send_keys(Keys.CONTROL + 'a')
    g._element.send_keys(Keys.DELETE)
    g._element.send_keys(text)
    if world.is_firefox():
        world.trigger_event('div.CodeMirror', index=index, event='blur')
예제 #18
0
def type_in_codemirror(index, text):
    world.css_click("div.CodeMirror-lines", index=index)
    world.browser.execute_script("$('div.CodeMirror.CodeMirror-focused > div').css('overflow', '')")
    g = world.css_find("div.CodeMirror.CodeMirror-focused > div > textarea")
    if world.is_mac():
        g._element.send_keys(Keys.COMMAND + 'a')
    else:
        g._element.send_keys(Keys.CONTROL + 'a')
    g._element.send_keys(Keys.DELETE)
    g._element.send_keys(text)
    if world.is_firefox():
        world.trigger_event('div.CodeMirror', index=index, event='blur')
예제 #19
0
def type_in_codemirror(index, text):
    world.wait(1)  # For now, slow this down so that it works. TODO: fix it.
    world.css_click("div.CodeMirror-lines", index=index)
    world.browser.execute_script("$('div.CodeMirror.CodeMirror-focused > div').css('overflow', '')")
    g = world.css_find("div.CodeMirror.CodeMirror-focused > div > textarea")
    if world.is_mac():
        g._element.send_keys(Keys.COMMAND + "a")
    else:
        g._element.send_keys(Keys.CONTROL + "a")
    g._element.send_keys(Keys.DELETE)
    g._element.send_keys(text)
    if world.is_firefox():
        world.trigger_event("div.CodeMirror", index=index, event="blur")
예제 #20
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)
예제 #21
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)
예제 #22
0
def press_the_notification_button(_step, name):
    css = 'a.action-%s' % name.lower()

    # The button was clicked if either the notification bar is gone,
    # or we see an error overlaying it (expected for invalid inputs).
    def button_clicked():
        confirmation_dismissed = world.is_css_not_present('.is-shown.wrapper-notification-warning')
        error_showing = world.is_css_present('.is-shown.wrapper-notification-error')
        return confirmation_dismissed or error_showing
    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(css, event='focus')
        world.browser.execute_script("$('{}').click()".format(css))
    else:
        world.css_click(css, success_condition=button_clicked), '%s button not clicked after 5 attempts.' % name
예제 #23
0
def press_the_notification_button(_step, name):
    css = 'a.action-%s' % name.lower()

    # The button was clicked if either the notification bar is gone,
    # or we see an error overlaying it (expected for invalid inputs).
    def button_clicked():
        confirmation_dismissed = world.is_css_not_present('.is-shown.wrapper-notification-warning')
        error_showing = world.is_css_present('.is-shown.wrapper-notification-error')
        return confirmation_dismissed or error_showing
    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(css, event='focus')
        world.browser.execute_script("$('{}').click()".format(css))
    else:
        world.css_click(css, success_condition=button_clicked), '%s button not clicked after 5 attempts.' % name
예제 #24
0
def type_in_codemirror(index, text):
    world.wait(1)  # For now, slow this down so that it works. TODO: fix it.
    world.css_click("div.CodeMirror-lines", index=index)
    world.browser.execute_script(
        "$('div.CodeMirror.CodeMirror-focused > div').css('overflow', '')")
    g = world.css_find("div.CodeMirror.CodeMirror-focused > div > textarea")
    if world.is_mac():
        g._element.send_keys(Keys.COMMAND + 'a')
    else:
        g._element.send_keys(Keys.CONTROL + 'a')
    g._element.send_keys(Keys.DELETE)
    g._element.send_keys(text)
    if world.is_firefox():
        world.trigger_event('div.CodeMirror', index=index, event='blur')
    world.wait_for_ajax_complete()
예제 #25
0
def asset_chapter(_step, name, ordinal):
    index = ["first", "second", "third"].index(ordinal)
    input_css = ".textbook .chapter{i} input.chapter-asset-path".format(i=index+1)
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
예제 #26
0
def name_textbook(_step, name):
    input_css = ".textbook input[name=textbook-name]"
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
예제 #27
0
def i_can_modify_the_display_name_with_special_chars(_step):
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input', "updated ' \" &", index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    verify_modified_display_name_with_special_chars()
예제 #28
0
def set_weight(weight):
    index = world.get_setting_entry_index(PROBLEM_WEIGHT)
    world.css_fill('.wrapper-comp-setting .setting-input', weight, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index, event='blur')
        world.trigger_event('a.save-button', event='focus')
def name_textbook(_step, name):
    input_css = ".textbook input[name=textbook-name]"
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)