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

Side by Side Diff: tools/testing/run_selenium.py

Issue 9960050: Add runtime=dartium webdriver support to test.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 """Script to actually open a browser and perform the test, and reports back with 8 """Script to actually open a browser and perform the test, and reports back with
9 the result. It uses Selenium WebDriver when possible for running the tests. It 9 the result. It uses Selenium WebDriver when possible for running the tests. It
10 uses Selenium RC for Safari. 10 uses Selenium RC for Safari.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return source 107 return source
108 108
109 def parse_args(args=None): 109 def parse_args(args=None):
110 parser = optparse.OptionParser() 110 parser = optparse.OptionParser()
111 parser.add_option('--out', dest='out', 111 parser.add_option('--out', dest='out',
112 help = 'The path for html output file that we will running our test from', 112 help = 'The path for html output file that we will running our test from',
113 action = 'store', default = '') 113 action = 'store', default = '')
114 parser.add_option('--browser', dest='browser', 114 parser.add_option('--browser', dest='browser',
115 help = 'The browser type (default = chrome)', 115 help = 'The browser type (default = chrome)',
116 action = 'store', default = 'chrome') 116 action = 'store', default = 'chrome')
117 parser.add_option('--executable', dest='executable',
118 help = 'The browser executable path (only for browser=dartium)',
119 action = 'store', default = None)
117 # TODO(efortuna): Put this back up to be more than the default timeout in 120 # TODO(efortuna): Put this back up to be more than the default timeout in
118 # test.dart. Right now it needs to be less than 60 so that when test.dart 121 # test.dart. Right now it needs to be less than 60 so that when test.dart
119 # times out, this script also closes the browser windows. 122 # times out, this script also closes the browser windows.
120 parser.add_option('--timeout', dest = 'timeout', 123 parser.add_option('--timeout', dest = 'timeout',
121 help = 'Amount of time (seconds) to wait before timeout', type = 'int', 124 help = 'Amount of time (seconds) to wait before timeout', type = 'int',
122 action = 'store', default=58) 125 action = 'store', default=58)
123 parser.add_option('--mode', dest = 'mode', 126 parser.add_option('--mode', dest = 'mode',
124 help = 'The type of test we are running', 127 help = 'The type of test we are running',
125 action = 'store', default='correctness') 128 action = 'store', default='correctness')
126 args, ignored = parser.parse_args(args=args) 129 args, _ = parser.parse_args(args=args)
127 return args.out, args.browser, args.timeout, args.mode 130 if args.executable and args.browser != 'dartium':
131 print 'Executable path only supported when browser=dartium.'
132 sys.exit(1)
133 return args.out, args.browser, args.executable, args.timeout, args.mode
128 134
129 def start_browser(browser, html_out): 135 def start_browser(browser, browser_path, html_out):
130 if browser == 'chrome': 136 if browser == 'chrome':
131 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to 137 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
132 # installing Chrome. Also note that the build bot runs have a different path 138 # installing Chrome. Also note that the build bot runs have a different path
133 # from a normal user -- check the build logs. 139 # from a normal user -- check the build logs.
134 return selenium.webdriver.Chrome() 140 return selenium.webdriver.Chrome()
135 elif browser == 'dartium': 141 elif browser == 'dartium':
136 script_dir = os.path.dirname(os.path.abspath(__file__)) 142 script_dir = os.path.dirname(os.path.abspath(__file__))
137 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests', 143 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests',
138 'dartium') 144 'dartium')
139 options = selenium.webdriver.chrome.options.Options() 145 options = selenium.webdriver.chrome.options.Options()
140 if platform.system() == 'Windows': 146 if browser_path is not None:
147 options.binary_location = browser_path
148 elif platform.system() == 'Windows':
141 options.binary_location = os.path.join(dartium_dir, 'chrome.exe') 149 options.binary_location = os.path.join(dartium_dir, 'chrome.exe')
142 elif platform.system() == 'Darwin': 150 elif platform.system() == 'Darwin':
143 options.binary_location = os.path.join(dartium_dir, 'Chromium.app', 151 options.binary_location = os.path.join(dartium_dir, 'Chromium.app',
144 'Contents', 'MacOS', 'Chromium') 152 'Contents', 'MacOS', 'Chromium')
145 else: 153 else:
146 options.binary_location = os.path.join(dartium_dir, 'chrome') 154 options.binary_location = os.path.join(dartium_dir, 'chrome')
147 return selenium.webdriver.Chrome(chrome_options=options) 155 return selenium.webdriver.Chrome(chrome_options=options)
148 elif browser == 'ff': 156 elif browser == 'ff':
149 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile() 157 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
150 profile.set_preference('dom.max_script_run_time', 0) 158 profile.set_preference('dom.max_script_run_time', 0)
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 close_browser(browser) 293 close_browser(browser)
286 294
287 295
288 def main(args): 296 def main(args):
289 # Run in batch mode if the --batch flag is passed. 297 # Run in batch mode if the --batch flag is passed.
290 # TODO(jmesserly): reconcile with the existing args parsing 298 # TODO(jmesserly): reconcile with the existing args parsing
291 if '--batch' in args: 299 if '--batch' in args:
292 return run_batch_tests() 300 return run_batch_tests()
293 301
294 # Run a single test 302 # Run a single test
295 html_out, browser_name, timeout, mode = parse_args() 303 html_out, browser_name, browser_path, timeout, mode = parse_args()
296 browser = start_browser(browser_name, html_out) 304 browser = start_browser(browser_name, browser_path, html_out)
297 305
298 try: 306 try:
299 output = run_test_in_browser(browser, html_out, timeout, mode) 307 output = run_test_in_browser(browser, html_out, timeout, mode)
300 return report_results(mode, output) 308 return report_results(mode, output)
301 finally: 309 finally:
302 close_browser(browser) 310 close_browser(browser)
303 311
304 if __name__ == "__main__": 312 if __name__ == "__main__":
305 sys.exit(main(sys.argv)) 313 sys.exit(main(sys.argv))
OLDNEW
« tools/testing/dart/test_options.dart ('K') | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698