Bug 1336022 - Fix test_window_handles_after_opening_new_tab by waiting for the page loaded in the new tab. r=whimboo draft
authoranjul tyagi <anjul.ten@gmail.com>
Fri, 10 Feb 2017 17:00:17 +0530
changeset 486086 23bac522fd87e22f5aa82f4dd53091842b4519a7
parent 479303 1cc159c7a0445ec51e335c8a1a1cceea7bbf8380
child 546172 ecd6a4ecd4175966945f35baed7979c0ec301d12
push id45903
push userbmo:anjul.ten@gmail.com
push dateFri, 17 Feb 2017 15:20:57 +0000
reviewerswhimboo
bugs1336022
milestone54.0a1
Bug 1336022 - Fix test_window_handles_after_opening_new_tab by waiting for the page loaded in the new tab. r=whimboo MozReview-Commit-ID: ExmUG2vApbl
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
@@ -1,13 +1,13 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-from marionette_driver import By
+from marionette_driver import By, Wait
 
 from marionette_harness import MarionetteTestCase, WindowManagerMixin
 
 
 class TestWindowHandles(WindowManagerMixin, MarionetteTestCase):
 
     def setUp(self):
         super(TestWindowHandles, self).setUp()
@@ -27,17 +27,19 @@ class TestWindowHandles(WindowManagerMix
             link.click()
 
         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)
 
         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, timeout=self.marionette.timeout.page_load).until(
+            lambda mn: mn.get_url() == self.empty_page,
+            message="{} did not load after opening a new tab".format(self.empty_page))
 
         self.marionette.switch_to_window(self.start_tab)
         self.assertEqual(self.marionette.current_window_handle, self.start_tab)
         self.assertEqual(self.marionette.get_url(), self.test_page)
 
         self.marionette.switch_to_window(new_tab)
         self.marionette.close()
         self.assertEqual(len(self.marionette.window_handles), len(self.start_tabs))