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

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

Issue 11098028: Revert r13442. The extension fails to install under Windows, and the sentinel (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « pkg/unittest/test_controller.js ('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
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 """Provide the user an informative error message if we attempt to connect to 134 """Provide the user an informative error message if we attempt to connect to
135 the Selenium remote control server, but cannot access it. Then exit the 135 the Selenium remote control server, but cannot access it. Then exit the
136 program.""" 136 program."""
137 print ('ERROR: Could not connect to Selenium RC server. Are you running' 137 print ('ERROR: Could not connect to Selenium RC server. Are you running'
138 ' java -jar tools/testing/selenium-server-standalone-*.jar? If not, ' 138 ' java -jar tools/testing/selenium-server-standalone-*.jar? If not, '
139 'start it before running this test.') 139 'start it before running this test.')
140 sys.exit(1) 140 sys.exit(1)
141 141
142 def start_browser(browser, executable_path, html_out): 142 def start_browser(browser, executable_path, html_out):
143 if browser == 'chrome': 143 if browser == 'chrome':
144 script_dir = os.path.dirname(os.path.abspath(__file__))
145 crx = os.path.join(script_dir, 'extensions', 'chrome',
146 'ConsoleCollector.crx')
147 options = selenium.webdriver.chrome.options.Options()
148 options.add_extension(crx)
149 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to 144 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
150 # installing Chrome. Also note that the build bot runs have a different path 145 # installing Chrome. Also note that the build bot runs have a different path
151 # from a normal user -- check the build logs. 146 # from a normal user -- check the build logs.
152 return selenium.webdriver.Chrome(chrome_options=options) 147 return selenium.webdriver.Chrome()
153 elif browser == 'dartium': 148 elif browser == 'dartium':
154 script_dir = os.path.dirname(os.path.abspath(__file__)) 149 script_dir = os.path.dirname(os.path.abspath(__file__))
155 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests', 150 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests',
156 'dartium') 151 'dartium')
157 crx = os.path.join(script_dir, 'extensions', 'chrome',
158 'ConsoleCollector.crx')
159 options = selenium.webdriver.chrome.options.Options() 152 options = selenium.webdriver.chrome.options.Options()
160 options.add_extension(crx)
161 # enable ShadowDOM and style scoped for Dartium 153 # enable ShadowDOM and style scoped for Dartium
162 options.add_argument('--enable-shadow-dom') 154 options.add_argument('--enable-shadow-dom')
163 options.add_argument('--enable-style-scoped') 155 options.add_argument('--enable-style-scoped')
164 if executable_path is not None: 156 if executable_path is not None:
165 options.binary_location = executable_path 157 options.binary_location = executable_path
166 elif platform.system() == 'Windows': 158 elif platform.system() == 'Windows':
167 options.binary_location = os.path.join(dartium_dir, 'chrome.exe') 159 options.binary_location = os.path.join(dartium_dir, 'chrome.exe')
168 elif platform.system() == 'Darwin': 160 elif platform.system() == 'Darwin':
169 options.binary_location = os.path.join(dartium_dir, 'Chromium.app', 161 options.binary_location = os.path.join(dartium_dir, 'Chromium.app',
170 'Contents', 'MacOS', 'Chromium') 162 'Contents', 'MacOS', 'Chromium')
171 else: 163 else:
172 options.binary_location = os.path.join(dartium_dir, 'chrome') 164 options.binary_location = os.path.join(dartium_dir, 'chrome')
173 return selenium.webdriver.Chrome(chrome_options=options) 165 return selenium.webdriver.Chrome(chrome_options=options)
174 elif browser == 'ff': 166 elif browser == 'ff':
175 script_dir = os.path.dirname(os.path.abspath(__file__)) 167 script_dir = os.path.dirname(os.path.abspath(__file__))
176 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile() 168 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
177 profile.set_preference('dom.max_script_run_time', 0) 169 profile.set_preference('dom.max_script_run_time', 0)
178 profile.set_preference('dom.max_chrome_script_run_time', 0) 170 profile.set_preference('dom.max_chrome_script_run_time', 0)
179 profile.set_preference('app.update.auto', True) 171 profile.set_preference('app.update.auto', True)
180 profile.set_preference('app.update.enabled', True) 172 profile.set_preference('app.update.enabled', True)
181 xpi = os.path.join(script_dir, 'extensions', 'firefox', 173 xpi = os.path.join(script_dir, 'extensions', 'firefox', 'ConsoleCollector.xpi')
182 'ConsoleCollector.xpi')
183 profile.add_extension(xpi); 174 profile.add_extension(xpi);
184 return selenium.webdriver.Firefox(firefox_profile=profile) 175 return selenium.webdriver.Firefox(firefox_profile=profile)
185 elif browser == 'ie' and platform.system() == 'Windows': 176 elif browser == 'ie' and platform.system() == 'Windows':
186 return selenium.webdriver.Ie() 177 return selenium.webdriver.Ie()
187 elif browser == 'safari' and platform.system() == 'Darwin': 178 elif browser == 'safari' and platform.system() == 'Darwin':
188 # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the 179 # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the
189 # same (Safari auto-deletes when it has too many "crashes," or in our case, 180 # same (Safari auto-deletes when it has too many "crashes," or in our case,
190 # timeouts). Come up with a less hacky way to do this. 181 # timeouts). Come up with a less hacky way to do this.
191 backup_safari_prefs = os.path.dirname(__file__) + '/com.apple.Safari.plist' 182 backup_safari_prefs = os.path.dirname(__file__) + '/com.apple.Safari.plist'
192 if os.path.exists(backup_safari_prefs): 183 if os.path.exists(backup_safari_prefs):
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 print 'Content-Type: text/plain\nPASS' 237 print 'Content-Type: text/plain\nPASS'
247 return 0 238 return 0
248 else: 239 else:
249 #The hacky way to get document.getElementById('body').innerHTML for this 240 #The hacky way to get document.getElementById('body').innerHTML for this
250 # webpage, without the JavaScript. 241 # webpage, without the JavaScript.
251 #TODO(efortuna): Access these elements in a nicer way using DOM parser. 242 #TODO(efortuna): Access these elements in a nicer way using DOM parser.
252 index = source.find('<body>') 243 index = source.find('<body>')
253 index += len('<body>') 244 index += len('<body>')
254 end_index = source.find('</body') 245 end_index = source.find('</body')
255 print unicode(source[index : end_index]).encode("utf-8") 246 print unicode(source[index : end_index]).encode("utf-8")
256 logs = []
257 if type(browser) is selenium.webdriver.firefox.webdriver.WebDriver: 247 if type(browser) is selenium.webdriver.firefox.webdriver.WebDriver:
258 logs = browser.execute_script("return window.ConsoleCollector.read()"); 248 logs = browser.execute_script("return window.ConsoleCollector.read()");
259 elif type(browser) is selenium.webdriver.chrome.webdriver.WebDriver: 249 for msg in logs:
260 browser.set_script_timeout(100) 250 print('%s:%s:%s:%s %s' %(
261 logs = browser.execute_async_script( 251 msg['source'], msg['line'], msg['column'],
262 "getMessages(arguments[arguments.length-1])"); 252 msg['category'], msg['message']))
263 for msg in logs:
264 print('%s:%s:%s %s' %(
265 msg['source'], msg['line'], msg['category'], msg['message']))
266 return 1 253 return 1
267 254
268 255
269 def run_batch_tests(): 256 def run_batch_tests():
270 ''' 257 '''
271 Runs a batch of in-browser tests in the same browser process. Batching 258 Runs a batch of in-browser tests in the same browser process. Batching
272 gives faster throughput and makes tests less subject to browser starting 259 gives faster throughput and makes tests less subject to browser starting
273 flakiness, issues with too many browser processes running, etc. 260 flakiness, issues with too many browser processes running, etc.
274 261
275 When running this function, stdin/stdout is used to communicate with the test 262 When running this function, stdin/stdout is used to communicate with the test
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 browser = start_browser(browser_name, executable_path, html_out) 337 browser = start_browser(browser_name, executable_path, html_out)
351 338
352 try: 339 try:
353 output = run_test_in_browser(browser, html_out, timeout, mode) 340 output = run_test_in_browser(browser, html_out, timeout, mode)
354 return report_results(mode, output, browser) 341 return report_results(mode, output, browser)
355 finally: 342 finally:
356 close_browser(browser) 343 close_browser(browser)
357 344
358 if __name__ == "__main__": 345 if __name__ == "__main__":
359 sys.exit(main(sys.argv)) 346 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « pkg/unittest/test_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698