From cb02b62b7c5bd2eae3dc366d402c9b9ebc97123c Mon Sep 17 00:00:00 2001 From: raeeschachar Date: Tue, 6 Oct 2015 01:22:41 +0500 Subject: [PATCH] Fixed test_undo_changes and test_manaul_change that were failing on Chrome --- .../pages/studio/settings_advanced.py | 17 +++++++++++++++++ .../tests/studio/test_studio_settings.py | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/test/acceptance/pages/studio/settings_advanced.py b/common/test/acceptance/pages/studio/settings_advanced.py index c96ce12e7f..9b17494151 100644 --- a/common/test/acceptance/pages/studio/settings_advanced.py +++ b/common/test/acceptance/pages/studio/settings_advanced.py @@ -48,11 +48,26 @@ class AdvancedSettingsPage(CoursePage): self.browser.refresh() self.wait_for_page() + def coordinates_for_scrolling(self, coordinates_for): + """ + Get the x and y coordinates of elements + """ + cordinates_dict = self.browser.find_element_by_css_selector(coordinates_for) + location = cordinates_dict.location + for key, val in location.iteritems(): + if key == 'x': + x_axis = val + elif key == 'y': + y_axis = val + return x_axis, y_axis + def undo_changes_via_modal(self): """ Trigger clicking event of the undo changes button in the modal. Wait for the undoing process to load via ajax call. + Before that Scroll so the button is clickable on all browsers """ + self.browser.execute_script("window.scrollTo" + str(self.coordinates_for_scrolling(UNDO_BUTTON_SELECTOR))) self.q(css=UNDO_BUTTON_SELECTOR).click() self.wait_for_ajax() @@ -60,7 +75,9 @@ class AdvancedSettingsPage(CoursePage): """ Trigger click event of the manual changes button in the modal. No need to wait for any ajax. + Before that Scroll so the button is clickable on all browsers """ + self.browser.execute_script("window.scrollTo" + str(self.coordinates_for_scrolling(MANUAL_BUTTON_SELECTOR))) self.q(css=MANUAL_BUTTON_SELECTOR).click() def is_validation_modal_present(self): diff --git a/common/test/acceptance/tests/studio/test_studio_settings.py b/common/test/acceptance/tests/studio/test_studio_settings.py index e114b6366c..8b894d0e7f 100644 --- a/common/test/acceptance/tests/studio/test_studio_settings.py +++ b/common/test/acceptance/tests/studio/test_studio_settings.py @@ -306,7 +306,7 @@ class AdvancedSettingsValidationTest(StudioCourseTest): # Let modal popup self.advanced_settings.wait_for_modal_load() - # Press Undo Changes button + # Click Undo Changes button self.advanced_settings.undo_changes_via_modal() # Check that changes are undone @@ -337,8 +337,6 @@ class AdvancedSettingsValidationTest(StudioCourseTest): # Iterate through the wrong values and make sure they're still displayed for key, val in inputs.iteritems(): - print self.advanced_settings.get(key) - print val self.assertEquals( str(self.advanced_settings.get(key)), str(val),