Bug 1344647 - Wait for the web page being loaded in a newly opened tab. r=whimboo, a=test-only
authorNitish <nitishplus98@gmail.com>
Fri, 10 Mar 2017 19:38:01 +0530
changeset 379130 5715f53e02fd1f616d083878aa3da07a3836c75a
parent 379129 2a28f378103f451a43202764f024f7c1ec763681
child 379131 8fb079895e7ba6192aad7de5fafdc54f0117a1ee
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo, test-only
bugs1344647
milestone53.0
Bug 1344647 - Wait for the web page being loaded in a newly opened tab. r=whimboo, a=test-only MozReview-Commit-ID: 49qx8UZb8Jy
testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_content.py
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_content.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_handles_content.py
@@ -55,17 +55,19 @@ class TestWindowHandles(WindowManagerMix
         # We open a new window but are actually interested in the new tab
         new_tab = self.open_tab(trigger=open_with_link)
         self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
         self.assertEqual(self.marionette.current_window_handle, self.start_tab)
 
         # Check that the new tab has the correct page loaded
         self.marionette.switch_to_window(new_tab)
         self.assertEqual(self.marionette.current_window_handle, new_tab)
-        self.assertEqual(self.marionette.get_url(), self.empty_page)
+        Wait(self.marionette, self.marionette.timeout.page_load).until(
+            lambda _: self.marionette.get_url() == self.empty_page,
+            message="The expected page '{}' has not been loaded".format(self.empty_page))
 
         # Ensure navigate works in our current window
         other_page = self.marionette.absolute_url("test.html")
         self.marionette.navigate(other_page)
         self.assertEqual(self.marionette.get_url(), other_page)
 
         # Close the opened window and carry on in our original tab.
         self.marionette.close()
@@ -84,9 +86,11 @@ class TestWindowHandles(WindowManagerMix
         self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs) + 1)
         self.assertEqual(self.marionette.current_window_handle, self.start_tab)
 
         self.marionette.close()
         self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))
 
         self.marionette.switch_to_window(new_tab)
         self.assertEqual(self.marionette.current_window_handle, new_tab)
-        self.assertEqual(self.marionette.get_url(), self.empty_page)
+        Wait(self.marionette, self.marionette.timeout.page_load).until(
+            lambda _: self.marionette.get_url() == self.empty_page,
+            message="The expected page '{}' has not been loaded".format(self.empty_page))