From 46d0e5ed0538dcffe83497f39a876863a1680899 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Fri, 2 Aug 2013 14:34:24 -0400 Subject: [PATCH] Fixed display-name bug and added in a function to trigger events on firefox as well as check if it is firefox --- cms/djangoapps/contentstore/features/common.py | 2 +- .../component_settings_editor_helpers.py | 10 +++++++++- .../contentstore/features/problem-editor.py | 16 ++++++++++++---- cms/djangoapps/contentstore/features/video.py | 2 +- common/djangoapps/terrain/ui_helpers.py | 7 +++++++ 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index b34ce71ed2..b3b7ff3115 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -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 diff --git a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py index 5db979bfa2..23b9d21850 100644 --- a/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py +++ b/cms/djangoapps/contentstore/features/component_settings_editor_helpers.py @@ -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 diff --git a/cms/djangoapps/contentstore/features/problem-editor.py b/cms/djangoapps/contentstore/features/problem-editor.py index d7ccb557ba..284d4fa41d 100644 --- a/cms/djangoapps/contentstore/features/problem-editor.py +++ b/cms/djangoapps/contentstore/features/problem-editor.py @@ -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(): diff --git a/cms/djangoapps/contentstore/features/video.py b/cms/djangoapps/contentstore/features/video.py index e0d570accd..7c0a1464d3 100644 --- a/cms/djangoapps/contentstore/features/video.py +++ b/cms/djangoapps/contentstore/features/video.py @@ -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) diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 2b81e9bd7f..11b8b6390d 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -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):