diff --git a/common/test/acceptance/pages/lms/discussion.py b/common/test/acceptance/pages/lms/discussion.py index 049d83b9d6..a16f33819d 100644 --- a/common/test/acceptance/pages/lms/discussion.py +++ b/common/test/acceptance/pages/lms/discussion.py @@ -354,12 +354,11 @@ class DiscussionTabSingleThreadPage(CoursePage): with self.thread_page._secondary_action_menu_open(".forum-thread-main-wrapper"): self._find_within(".forum-thread-main-wrapper .action-close").first.click() - @wait_for_js - def is_window_on_top(self): + def is_focused_on_element(self, selector): """ - Check if window's scroll is at top + Check if the focus is on element """ - return self.browser.execute_script("return $('html, body').offset().top") == 0 + return self.browser.execute_script("return $('{}').is(':focus')".format(selector)) def _thread_is_rendered_successfully(self, thread_id): return self.q(css=".discussion-article[data-id='{}']".format(thread_id)).visible @@ -381,13 +380,13 @@ class DiscussionTabSingleThreadPage(CoursePage): """ return len(self.q(css=".forum-nav-thread").results) == thread_count - def check_window_is_on_top(self): + def check_focus_is_set(self, selector): """ - Check window is on top of the page + Check focus is set """ EmptyPromise( - self.is_window_on_top, - "Window is on top" + lambda: self.is_focused_on_element(selector), + "Focus is on other element" ).fulfill() diff --git a/common/test/acceptance/tests/discussion/test_discussion.py b/common/test/acceptance/tests/discussion/test_discussion.py index 3c57e2f855..e1f8d436b6 100644 --- a/common/test/acceptance/tests/discussion/test_discussion.py +++ b/common/test/acceptance/tests/discussion/test_discussion.py @@ -316,7 +316,7 @@ class DiscussionTabMultipleThreadTest(BaseDiscussionTestCase): def test_page_scroll_on_thread_change_view(self): """ - Check switching between threads changes the page to scroll to bottom + Check switching between threads changes the page focus """ # verify threads are rendered on the page self.assertTrue( @@ -327,8 +327,8 @@ class DiscussionTabMultipleThreadTest(BaseDiscussionTestCase): self.thread_page_1.click_and_open_thread(thread_id=self.thread_ids[1]) self.assertTrue(self.thread_page_2.is_browser_on_page()) - # Verify that window is on top of page. - self.thread_page_2.check_window_is_on_top() + # Verify that the focus is changed + self.thread_page_2.check_focus_is_set(selector=".discussion-article") @attr('shard_2')