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

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

Issue 12675002: [chromedriver] Implement command: executeAsyncScript and setScriptTimeout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 base64 8 import base64
9 import ctypes 9 import ctypes
10 import optparse 10 import optparse
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 'return {stuff: document.querySelectorAll("div")};') 136 'return {stuff: document.querySelectorAll("div")};')
137 stuff = self._driver.ExecuteScript(script)['stuff'] 137 stuff = self._driver.ExecuteScript(script)['stuff']
138 script = 'return arguments[0].innerHTML + arguments[1].innerHTML' 138 script = 'return arguments[0].innerHTML + arguments[1].innerHTML'
139 self.assertEquals( 139 self.assertEquals(
140 'bc', self._driver.ExecuteScript(script, stuff[0], stuff[1])) 140 'bc', self._driver.ExecuteScript(script, stuff[0], stuff[1]))
141 141
142 def testEvaluateInvalidScript(self): 142 def testEvaluateInvalidScript(self):
143 self.assertRaises(chromedriver.ChromeDriverException, 143 self.assertRaises(chromedriver.ChromeDriverException,
144 self._driver.ExecuteScript, '{{{') 144 self._driver.ExecuteScript, '{{{')
145 145
146 def testExecuteAsyncScript(self):
147 self._driver.SetTimeout('script', 3000)
148 self.assertRaises(
149 chromedriver.Timeout,
150 self._driver.ExecuteAsyncScript,
151 'var callback = arguments[0];'
152 'setTimeout(function(){callback(1);}, 10000);')
153 self.assertEquals(
154 2,
155 self._driver.ExecuteAsyncScript(
156 'var callback = arguments[0];'
157 'setTimeout(function(){callback(2);}, 300);'))
158
146 def testSwitchToFrame(self): 159 def testSwitchToFrame(self):
147 self._driver.ExecuteScript( 160 self._driver.ExecuteScript(
148 'var frame = document.createElement("iframe");' 161 'var frame = document.createElement("iframe");'
149 'frame.id="id";' 162 'frame.id="id";'
150 'frame.name="name";' 163 'frame.name="name";'
151 'document.body.appendChild(frame);') 164 'document.body.appendChild(frame);')
152 self.assertTrue(self._driver.ExecuteScript('return window.top == window')) 165 self.assertTrue(self._driver.ExecuteScript('return window.top == window'))
153 self._driver.SwitchToFrame('id') 166 self._driver.SwitchToFrame('id')
154 self.assertTrue(self._driver.ExecuteScript('return window.top != window')) 167 self.assertTrue(self._driver.ExecuteScript('return window.top != window'))
155 self._driver.SwitchToMainFrame() 168 self._driver.SwitchToMainFrame()
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 global _ANDROID_PACKAGE 436 global _ANDROID_PACKAGE
424 _ANDROID_PACKAGE = options.android_package 437 _ANDROID_PACKAGE = options.android_package
425 438
426 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 439 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
427 sys.modules[__name__]) 440 sys.modules[__name__])
428 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 441 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
429 ChromeDriverTest.GlobalSetUp() 442 ChromeDriverTest.GlobalSetUp()
430 result = unittest.TextTestRunner(stream=sys.stdout).run(tests) 443 result = unittest.TextTestRunner(stream=sys.stdout).run(tests)
431 ChromeDriverTest.GlobalTearDown() 444 ChromeDriverTest.GlobalTearDown()
432 sys.exit(len(result.failures) + len(result.errors)) 445 sys.exit(len(result.failures) + len(result.errors))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698