Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: chrome/test/chromedriver/run_py_tests.py

Issue 12224106: [chromedriver] Implement command: switchToWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ctypes 8 import ctypes
9 import optparse 9 import optparse
10 import os 10 import os
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) 60 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
61 window_count = len(self._driver.GetWindowHandles()) 61 window_count = len(self._driver.GetWindowHandles())
62 self._driver.FindElement('id', 'link').Click() 62 self._driver.FindElement('id', 'link').Click()
63 timeout = time.time() + 20 63 timeout = time.time() + 20
64 while time.time() < timeout: 64 while time.time() < timeout:
65 if (len(self._driver.GetWindowHandles()) > window_count): 65 if (len(self._driver.GetWindowHandles()) > window_count):
66 return 66 return
67 time.sleep(0.01) 67 time.sleep(0.01)
68 self.assertTrue(False) 68 self.assertTrue(False)
69 69
70 def testSwitchToWindow(self):
71 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
72 window1_handle = self._driver.GetCurrentWindowHandle()
73 window_count = len(self._driver.GetWindowHandles())
74 self._driver.FindElement('id', 'link').Click()
75 timeout = time.time() + 20
76 while time.time() < timeout:
77 all_handles = self._driver.GetWindowHandles()
78 if (len(all_handles) > window_count):
79 break
80 time.sleep(0.01)
81 self.assertTrue(window1_handle in all_handles)
82 all_handles.remove(window1_handle)
83 self._driver.SwitchToWindow(all_handles[0])
84 self.assertRaises(chromedriver.NoSuchElement,
85 self._driver.FindElement, 'id', 'link')
86
70 def testEvaluateScript(self): 87 def testEvaluateScript(self):
71 self.assertEquals(1, self._driver.ExecuteScript('return 1')) 88 self.assertEquals(1, self._driver.ExecuteScript('return 1'))
72 self.assertEquals(None, self._driver.ExecuteScript('')) 89 self.assertEquals(None, self._driver.ExecuteScript(''))
73 90
74 def testEvaluateScriptWithArgs(self): 91 def testEvaluateScriptWithArgs(self):
75 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' + 92 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' +
76 'return {stuff: document.querySelectorAll("div")};') 93 'return {stuff: document.querySelectorAll("div")};')
77 stuff = self._driver.ExecuteScript(script)['stuff'] 94 stuff = self._driver.ExecuteScript(script)['stuff']
78 script = 'return arguments[0].innerHTML + arguments[1].innerHTML' 95 script = 'return arguments[0].innerHTML + arguments[1].innerHTML'
79 self.assertEquals( 96 self.assertEquals(
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 global _ANDROID_PACKAGE 323 global _ANDROID_PACKAGE
307 _ANDROID_PACKAGE = options.android_package 324 _ANDROID_PACKAGE = options.android_package
308 325
309 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 326 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
310 sys.modules[__name__]) 327 sys.modules[__name__])
311 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 328 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
312 ChromeDriverTest.GlobalSetUp() 329 ChromeDriverTest.GlobalSetUp()
313 result = unittest.TextTestRunner().run(tests) 330 result = unittest.TextTestRunner().run(tests)
314 ChromeDriverTest.GlobalTearDown() 331 ChromeDriverTest.GlobalTearDown()
315 sys.exit(len(result.failures) + len(result.errors)) 332 sys.exit(len(result.failures) + len(result.errors))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698