OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """End to end tests for ChromeDriver.""" | 6 """End to end tests for ChromeDriver.""" |
7 | 7 |
8 import base64 | 8 import base64 |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Args: | 147 Args: |
148 old_handles: Handles to all old windows before the new window is added. | 148 old_handles: Handles to all old windows before the new window is added. |
149 | 149 |
150 Returns: | 150 Returns: |
151 Handle to a new window. None if timeout. | 151 Handle to a new window. None if timeout. |
152 """ | 152 """ |
153 timeout = time.time() + 20 | 153 timeout = time.time() + 20 |
154 while time.time() < timeout: | 154 while time.time() < timeout: |
155 new_handles = self._driver.GetWindowHandles() | 155 new_handles = self._driver.GetWindowHandles() |
156 if len(new_handles) > len(old_handles): | 156 if len(new_handles) > len(old_handles): |
157 for old_handle in old_handles: | 157 for index, old_handle in enumerate(old_handles): |
158 self.assertTrue(old_handle in new_handles) | 158 self.assertEquals(old_handle, new_handles[index]) |
159 new_handles.remove(old_handle) | 159 return new_handles[len(old_handles)] |
160 self.assertTrue(len(new_handles)) | |
161 return new_handles[0] | |
162 time.sleep(0.01) | 160 time.sleep(0.01) |
163 return None | 161 return None |
164 | 162 |
165 def testCloseWindow(self): | 163 def testCloseWindow(self): |
166 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) | 164 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) |
167 old_handles = self._driver.GetWindowHandles() | 165 old_handles = self._driver.GetWindowHandles() |
168 self._driver.FindElement('id', 'link').Click() | 166 self._driver.FindElement('id', 'link').Click() |
169 new_window_handle = self._WaitForNewWindow(old_handles) | 167 new_window_handle = self._WaitForNewWindow(old_handles) |
170 self.assertNotEqual(None, new_window_handle) | 168 self.assertNotEqual(None, new_window_handle) |
171 self._driver.SwitchToWindow(new_window_handle) | 169 self._driver.SwitchToWindow(new_window_handle) |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 negative_filter = _DESKTOP_NEGATIVE_FILTER[options.chrome_revision] | 555 negative_filter = _DESKTOP_NEGATIVE_FILTER[options.chrome_revision] |
558 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) | 556 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) |
559 | 557 |
560 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 558 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
561 sys.modules[__name__]) | 559 sys.modules[__name__]) |
562 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 560 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
563 ChromeDriverTest.GlobalSetUp() | 561 ChromeDriverTest.GlobalSetUp() |
564 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) | 562 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) |
565 ChromeDriverTest.GlobalTearDown() | 563 ChromeDriverTest.GlobalTearDown() |
566 sys.exit(len(result.failures) + len(result.errors)) | 564 sys.exit(len(result.failures) + len(result.errors)) |
OLD | NEW |