Fixed display-name bug and added in a function to trigger events on firefox as well as check if it is firefox
This commit is contained in:
@@ -70,7 +70,7 @@ def press_the_notification_button(_step, name):
|
||||
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.browser.driver_name == 'Firefox':
|
||||
if world.is_firefox():
|
||||
world.browser.execute_script("$('{}').click()".format(css))
|
||||
else:
|
||||
world.css_click(css, success_condition=button_clicked), '%s button not clicked after 5 attempts.' % name
|
||||
|
||||
@@ -56,7 +56,7 @@ def click_component_from_menu(category, boilerplate, expected_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')
|
||||
world.css_click('#settings-mode a')
|
||||
|
||||
|
||||
@world.absorb
|
||||
@@ -119,3 +119,11 @@ def get_setting_entry(label):
|
||||
if setting.find_by_css('.setting-label')[0].value == label:
|
||||
return setting
|
||||
return None
|
||||
|
||||
@world.absorb
|
||||
def get_setting_entry_index(label):
|
||||
settings = world.browser.find_by_css('.wrapper-comp-setting')
|
||||
for index, setting in enumerate(settings):
|
||||
if setting.find_by_css('.setting-label')[0].value == label:
|
||||
return index
|
||||
return None
|
||||
|
||||
@@ -45,7 +45,10 @@ def i_see_five_settings_with_values(step):
|
||||
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).
|
||||
world.get_setting_entry(DISPLAY_NAME).find_by_css('.setting-input')[0].fill('3.4')
|
||||
index = world.get_setting_entry_index(DISPLAY_NAME)
|
||||
world.css_fill('.wrapper-comp-setting .setting-input', '3.4', index=index)
|
||||
if world.browser.driver_name == 'Firefox':
|
||||
world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
|
||||
verify_modified_display_name()
|
||||
|
||||
|
||||
@@ -57,7 +60,10 @@ def my_display_name_change_is_persisted_on_save(step):
|
||||
|
||||
@step('I can specify special characters in the display name')
|
||||
def i_can_modify_the_display_name_with_special_chars(step):
|
||||
world.get_setting_entry(DISPLAY_NAME).find_by_css('.setting-input')[0].fill("updated ' \" &")
|
||||
index = world.get_setting_entry_index(DISPLAY_NAME)
|
||||
world.css_fill('.wrapper-comp-setting .setting-input', "updated ' \" &", index=index)
|
||||
if world.browser.driver_name == 'Firefox':
|
||||
world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
|
||||
verify_modified_display_name_with_special_chars()
|
||||
|
||||
|
||||
@@ -129,7 +135,8 @@ def set_the_weight_to_abc(step, bad_weight):
|
||||
|
||||
@step('if I set the max attempts to "(.*)", it displays initially as "(.*)", and is persisted as "(.*)"')
|
||||
def set_the_max_attempts(step, max_attempts_set, max_attempts_displayed, max_attempts_persisted):
|
||||
world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill(max_attempts_set)
|
||||
index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS)
|
||||
world.css_fill('.wrapper-comp-setting .setting-input', max_attempts_set, index=index)
|
||||
world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, max_attempts_displayed, True)
|
||||
world.save_component_and_reopen(step)
|
||||
world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, max_attempts_persisted, True)
|
||||
@@ -213,7 +220,8 @@ def verify_unset_display_name():
|
||||
|
||||
|
||||
def set_weight(weight):
|
||||
world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill(weight)
|
||||
index = world.get_setting_entry_index(PROBLEM_WEIGHT)
|
||||
world.css_fill('.wrapper-comp-setting .setting-input', weight, index=index)
|
||||
|
||||
|
||||
def open_high_level_source():
|
||||
|
||||
@@ -33,7 +33,7 @@ def hide_or_show_captions(step, shown):
|
||||
# click the button rather than the tooltip, so move the mouse
|
||||
# away to make it disappear.
|
||||
button = world.css_find(button_css)
|
||||
if world.browser.driver_name != 'Firefox':
|
||||
if not world.is_firefox:
|
||||
button.mouse_out()
|
||||
world.css_click(button_css)
|
||||
|
||||
|
||||
@@ -235,6 +235,13 @@ def click_tools():
|
||||
def is_mac():
|
||||
return platform.mac_ver()[0] is not ''
|
||||
|
||||
@world.absorb
|
||||
def is_firefox():
|
||||
return world.browser.driver_name is 'Firefox'
|
||||
|
||||
@world.absorb
|
||||
def trigger_event(css_selector, event='change', index=0):
|
||||
world.browser.execute_script("$('{}:eq({})').trigger('{}')".format(css_selector, index, event))
|
||||
|
||||
@world.absorb
|
||||
def retry_on_exception(func, max_attempts=5):
|
||||
|
||||
Reference in New Issue
Block a user