From c39ebf1bc858fa088c652fd2f42fcb86fb073cab Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Mon, 22 Jun 2015 21:47:36 -0400 Subject: [PATCH 1/3] Wait for element to not be present. (Compatible with minor bok-choy upgrade.) With an upcoming bok-choy upgrade, 'not-present' and 'invisible' are two distinct concepts. In the upgrade, an invisible element must be present on the page. This commit draws that distinction across two helper methods, one for 'invisible' and the other for 'not-present' (or, not on the page at all). --- common/test/acceptance/pages/studio/users.py | 27 ++++++++++++++++--- .../tests/studio/test_studio_course_team.py | 2 +- .../tests/studio/test_studio_library.py | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/common/test/acceptance/pages/studio/users.py b/common/test/acceptance/pages/studio/users.py index d20bfbb56e..ca9d21aaee 100644 --- a/common/test/acceptance/pages/studio/users.py +++ b/common/test/acceptance/pages/studio/users.py @@ -107,18 +107,39 @@ class UsersPageMixin(PageObject): """ Gets modal dialog text """ return self.q(css='.prompt.{dialog_type} .message'.format(dialog_type=dialog_type)).text[0] + def wait_until_no_loading_indicator(self): + """ + When the page first loads, there is a loading indicator and most + functionality is not yet available. This waits for that loading to finish + and be removed from the DOM. + + This method is different from wait_until_ready because the loading element + is removed from the DOM, rather than hidden. + + It also disables animations for improved test reliability. + """ + + self.wait_for( + lambda: not self.q(css='.ui-loading').present, + "Wait for page to complete its initial loading" + ) + disable_animations(self) + def wait_until_ready(self): """ When the page first loads, there is a loading indicator and most functionality is not yet available. This waits for that loading to finish. - Always call this before using the page. It also disables animations - for improved test reliability. + This method is different from wait_until_backbone_rendered because this expects + the loading indicator to still exist on the page; it is just hidden. + + It also disables animations for improved test reliability. """ + self.wait_for_element_invisibility( '.ui-loading', - 'Wait for the page to complete its initial loading and rendering via Backbone' + 'Wait for the page to complete its initial loading' ) disable_animations(self) diff --git a/common/test/acceptance/tests/studio/test_studio_course_team.py b/common/test/acceptance/tests/studio/test_studio_course_team.py index d8f79f83fd..8e82b0f4ef 100644 --- a/common/test/acceptance/tests/studio/test_studio_course_team.py +++ b/common/test/acceptance/tests/studio/test_studio_course_team.py @@ -42,7 +42,7 @@ class CourseTeamPageTest(StudioCourseTest): def _go_to_course_team_page(self): """ Opens Course Team page """ self.page.visit() - self.page.wait_until_ready() + self.page.wait_until_no_loading_indicator() def _refresh_page(self): """ diff --git a/common/test/acceptance/tests/studio/test_studio_library.py b/common/test/acceptance/tests/studio/test_studio_library.py index 8e7bca4372..28fd99800a 100644 --- a/common/test/acceptance/tests/studio/test_studio_library.py +++ b/common/test/acceptance/tests/studio/test_studio_library.py @@ -523,7 +523,7 @@ class LibraryUsersPageTest(StudioLibraryTest): """ self.page = LibraryUsersPage(self.browser, self.library_key) self.page.visit() - self.page.wait_until_ready() + self.page.wait_until_no_loading_indicator() @flaky # TODO fix this; see TNL-2647 def test_user_management(self): From d8a649ae3606c53df80d77b8f882032ff20cd317 Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Fri, 26 Jun 2015 12:43:07 -0400 Subject: [PATCH 2/3] Use new bok-choy with invisible property. --- requirements/edx/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index da7fbb055d..7998b54822 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -124,7 +124,7 @@ django_debug_toolbar==1.2.2 # Used for testing astroid==1.3.4 -bok-choy==0.4.1 +bok-choy==0.4.2 chrono==1.0.2 coverage==3.7 ddt==0.8.0 From 8d9c16ba6e8f3cf1e00994a4b6ee9768427f088f Mon Sep 17 00:00:00 2001 From: Ben Patterson Date: Fri, 3 Jul 2015 06:54:56 -0700 Subject: [PATCH 3/3] Update comment to match method name. --- common/test/acceptance/pages/studio/users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/test/acceptance/pages/studio/users.py b/common/test/acceptance/pages/studio/users.py index ca9d21aaee..e8da392f46 100644 --- a/common/test/acceptance/pages/studio/users.py +++ b/common/test/acceptance/pages/studio/users.py @@ -131,7 +131,7 @@ class UsersPageMixin(PageObject): functionality is not yet available. This waits for that loading to finish. - This method is different from wait_until_backbone_rendered because this expects + This method is different from wait_until_no_loading_indicator because this expects the loading indicator to still exist on the page; it is just hidden. It also disables animations for improved test reliability.