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

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

Issue 11778011: [chromedriver]Add a filter to run a subset of tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 11 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
« no previous file with comments | « chrome/test/chromedriver/run_py_tests.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """End to end tests for ChromeDriver."""
6
7 import ctypes
8 import os
9 import sys
10 import unittest
11
12 import chromedriver
13
14
15 class ChromeDriverTest(unittest.TestCase):
16 """End to end tests for ChromeDriver."""
17
18 def testStartStop(self):
19 driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
20 driver.Quit()
21
22 def testLoadUrl(self):
23 driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
24 driver.Load('http://www.google.com')
25 driver.Quit()
26
27 def testEvaluateScript(self):
28 driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
29 self.assertEquals(1, driver.ExecuteScript('return 1'))
30 self.assertEquals(None, driver.ExecuteScript(''))
31 driver.Quit()
32
33 def testEvaluateScriptWithArgs(self):
34 driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
35 script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' +
36 'return {stuff: document.querySelectorAll("div")};')
37 stuff = driver.ExecuteScript(script)['stuff']
38 script = 'return arguments[0].innerHTML + arguments[1].innerHTML';
39 self.assertEquals('bc', driver.ExecuteScript(script, stuff[0], stuff[1]))
40 driver.Quit()
41
42 def testEvaluateInvalidScript(self):
43 driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
44 self.assertRaises(chromedriver.ChromeDriverException,
45 driver.ExecuteScript, '{{{')
46 driver.Quit()
47
48
49 if __name__ == '__main__':
50 if len(sys.argv) != 2 and len(sys.argv) != 3:
51 print ('Usage: %s <path_to_chromedriver_so> [path_to_chrome_binary]' %
52 __file__)
53 sys.exit(1)
54 global _CHROMEDRIVER_LIB
55 _CHROMEDRIVER_LIB = os.path.abspath(sys.argv[1])
56 global _CHROME_BINARY
57 if len(sys.argv) == 3:
58 _CHROME_BINARY = os.path.abspath(sys.argv[2])
59 else:
60 _CHROME_BINARY = None
61 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
62 sys.modules[__name__])
63 result = unittest.TextTestRunner().run(all_tests_suite)
64 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/run_py_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698