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

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: Enhance py testcase for switchToWindow. 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):
kkania 2013/02/12 01:33:04 add case for switching by window name too?
chrisgao (Use stgao instead) 2013/02/12 20:38:16 Done.
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.assertEquals(all_handles[0], self._driver.GetCurrentWindowHandle())
85 self.assertRaises(chromedriver.NoSuchElement,
86 self._driver.FindElement, 'id', 'link')
87
70 def testEvaluateScript(self): 88 def testEvaluateScript(self):
71 self.assertEquals(1, self._driver.ExecuteScript('return 1')) 89 self.assertEquals(1, self._driver.ExecuteScript('return 1'))
72 self.assertEquals(None, self._driver.ExecuteScript('')) 90 self.assertEquals(None, self._driver.ExecuteScript(''))
73 91
74 def testEvaluateScriptWithArgs(self): 92 def testEvaluateScriptWithArgs(self):
75 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' + 93 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' +
76 'return {stuff: document.querySelectorAll("div")};') 94 'return {stuff: document.querySelectorAll("div")};')
77 stuff = self._driver.ExecuteScript(script)['stuff'] 95 stuff = self._driver.ExecuteScript(script)['stuff']
78 script = 'return arguments[0].innerHTML + arguments[1].innerHTML' 96 script = 'return arguments[0].innerHTML + arguments[1].innerHTML'
79 self.assertEquals( 97 self.assertEquals(
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 global _ANDROID_PACKAGE 324 global _ANDROID_PACKAGE
307 _ANDROID_PACKAGE = options.android_package 325 _ANDROID_PACKAGE = options.android_package
308 326
309 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 327 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
310 sys.modules[__name__]) 328 sys.modules[__name__])
311 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 329 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
312 ChromeDriverTest.GlobalSetUp() 330 ChromeDriverTest.GlobalSetUp()
313 result = unittest.TextTestRunner().run(tests) 331 result = unittest.TextTestRunner().run(tests)
314 ChromeDriverTest.GlobalTearDown() 332 ChromeDriverTest.GlobalTearDown()
315 sys.exit(len(result.failures) + len(result.errors)) 333 sys.exit(len(result.failures) + len(result.errors))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698