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

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: Address +5000 timeout problem. 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 'return {stuff: document.querySelectorAll("div")};') 140 'return {stuff: document.querySelectorAll("div")};')
141 stuff = self._driver.ExecuteScript(script)['stuff'] 141 stuff = self._driver.ExecuteScript(script)['stuff']
142 script = 'return arguments[0].innerHTML + arguments[1].innerHTML' 142 script = 'return arguments[0].innerHTML + arguments[1].innerHTML'
143 self.assertEquals( 143 self.assertEquals(
144 'bc', self._driver.ExecuteScript(script, stuff[0], stuff[1])) 144 'bc', self._driver.ExecuteScript(script, stuff[0], stuff[1]))
145 145
146 def testEvaluateInvalidScript(self): 146 def testEvaluateInvalidScript(self):
147 self.assertRaises(chromedriver.ChromeDriverException, 147 self.assertRaises(chromedriver.ChromeDriverException,
148 self._driver.ExecuteScript, '{{{') 148 self._driver.ExecuteScript, '{{{')
149 149
150 def testExecuteAsyncScript(self):
151 self._driver.SetTimeout('script', 3000)
152 self.assertRaises(
153 chromedriver.ScriptTimeout,
154 self._driver.ExecuteAsyncScript,
155 'var callback = arguments[0];'
156 'setTimeout(function(){callback(1);}, 10000);')
157 self.assertEquals(
158 2,
159 self._driver.ExecuteAsyncScript(
160 'var callback = arguments[0];'
161 'setTimeout(function(){callback(2);}, 300);'))
162
150 def testSwitchToFrame(self): 163 def testSwitchToFrame(self):
151 self._driver.ExecuteScript( 164 self._driver.ExecuteScript(
152 'var frame = document.createElement("iframe");' 165 'var frame = document.createElement("iframe");'
153 'frame.id="id";' 166 'frame.id="id";'
154 'frame.name="name";' 167 'frame.name="name";'
155 'document.body.appendChild(frame);') 168 'document.body.appendChild(frame);')
156 self.assertTrue(self._driver.ExecuteScript('return window.top == window')) 169 self.assertTrue(self._driver.ExecuteScript('return window.top == window'))
157 self._driver.SwitchToFrame('id') 170 self._driver.SwitchToFrame('id')
158 self.assertTrue(self._driver.ExecuteScript('return window.top != window')) 171 self.assertTrue(self._driver.ExecuteScript('return window.top != window'))
159 self._driver.SwitchToMainFrame() 172 self._driver.SwitchToMainFrame()
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 global _ANDROID_PACKAGE 442 global _ANDROID_PACKAGE
430 _ANDROID_PACKAGE = options.android_package 443 _ANDROID_PACKAGE = options.android_package
431 444
432 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 445 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
433 sys.modules[__name__]) 446 sys.modules[__name__])
434 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 447 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
435 ChromeDriverTest.GlobalSetUp() 448 ChromeDriverTest.GlobalSetUp()
436 result = unittest.TextTestRunner(stream=sys.stdout).run(tests) 449 result = unittest.TextTestRunner(stream=sys.stdout).run(tests)
437 ChromeDriverTest.GlobalTearDown() 450 ChromeDriverTest.GlobalTearDown()
438 sys.exit(len(result.failures) + len(result.errors)) 451 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/js/execute_async_script_test.html ('k') | chrome/test/chromedriver/session_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698