Bug 1344647 - Wait for the web page being loaded in a newly opened tab draft
authorNitish <nitishplus98@gmail.com>
Fri, 10 Mar 2017 19:38:01 +0530
changeset 496710 8e024ee109742306f00b43ecf7a63a0a95deeeb6
parent 496661 92c5b7bcd598c55f88979c014acfb79fd1ad7e45
child 500987 4f117fd9591d1a067b3077280b3e2a1d07735e90
child 501900 94e25803070472d3c0d25ed6bc5cf11908ff4983
push id48665
push userbmo:nitishplus98@gmail.com
push dateFri, 10 Mar 2017 14:13:14 +0000
bugs1344647
milestone55.0a1
Bug 1344647 - Wait for the web page being loaded in a newly opened tab 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))