Commit f2c4a3de by raeeschachar

Merge pull request #10719 from edx/raees/chrome-bok-choy-test-page-scroll-on-thread-change-view

Fixes test_page_scroll_on_thread_change_view failing on chrome
parents cfa034ba b3271e3b
......@@ -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()
......
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment