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

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

Issue 12090067: Speculative fix for flakines on browser bots (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | « no previous file | 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 if isinstance(browser, selenium.selenium): 80 if isinstance(browser, selenium.selenium):
81 return run_test_in_browser_selenium_rc(browser, html_out, timeout, mode, 81 return run_test_in_browser_selenium_rc(browser, html_out, timeout, mode,
82 refresh) 82 refresh)
83 83
84 browser.get(html_out) 84 browser.get(html_out)
85 if refresh: 85 if refresh:
86 browser.refresh() 86 browser.refresh()
87 try: 87 try:
88 def pythonTimeout(): 88 def pythonTimeout():
89 close_browser(browser) 89 # The builtin quit call for chrome will call close on the RemoteDriver
90 # which may hang. Explicitly call browser.service.stop()
91 if (type(browser) is selenium.webdriver.chrome.webdriver.WebDriver):
92 # Browser may be dead
93 try:
94 browser.service.stop()
95 except:
96 print("Trying to close browser that has already been closed")
90 # If the browser is crashing selenium may not time out. 97 # If the browser is crashing selenium may not time out.
91 # Explicitly catch this case with a python timer. 98 # Explicitly catch this case with a python timer.
92 t = threading.Timer(timeout, pythonTimeout) 99 t = threading.Timer(timeout, pythonTimeout)
93 t.start() 100 t.start()
94 test_done = CONFIGURATIONS[mode] 101 test_done = CONFIGURATIONS[mode]
95 element = WebDriverWait(browser, float(timeout)).until( 102 element = WebDriverWait(browser, float(timeout)).until(
96 lambda driver: test_done(driver.page_source)) 103 lambda driver: test_done(driver.page_source))
97 t.cancel() 104 t.cancel()
98 return browser.page_source 105 return browser.page_source
99 except selenium.common.exceptions.TimeoutException: 106 except selenium.common.exceptions.TimeoutException:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return 237 return
231 if isinstance(browser, selenium.selenium): 238 if isinstance(browser, selenium.selenium):
232 browser.stop() 239 browser.stop()
233 return 240 return
234 241
235 # A timeout exception is thrown if nothing happens within the time limit. 242 # A timeout exception is thrown if nothing happens within the time limit.
236 if (type(browser) is not selenium.webdriver.chrome.webdriver.WebDriver and 243 if (type(browser) is not selenium.webdriver.chrome.webdriver.WebDriver and
237 type(browser) is not selenium.webdriver.ie.webdriver.WebDriver): 244 type(browser) is not selenium.webdriver.ie.webdriver.WebDriver):
238 browser.close() 245 browser.close()
239 246
240 # The builtin quit call will call close on the RemoteDriver which 247 browser.quit()
241 # may hang. Explicitly call browser.service.stop()
242 if (type(browser) is selenium.webdriver.chrome.webdriver.WebDriver):
243 # We may have called stop before if chrome was hanging.
244 try:
245 browser.service.stop()
246 except:
247 print("Trying to close browser that has already been closed")
248 pass
249 else:
250 browser.quit()
251 248
252 def report_results(mode, source, browser): 249 def report_results(mode, source, browser):
253 # TODO(vsm): Add a failure check for Dromaeo. 250 # TODO(vsm): Add a failure check for Dromaeo.
254 if mode != 'correctness': 251 if mode != 'correctness':
255 # We're running a performance test. 252 # We're running a performance test.
256 print source.encode('utf8') 253 print source.encode('utf8')
257 sys.stdout.flush() 254 sys.stdout.flush()
258 if 'NaN' in source: 255 if 'NaN' in source:
259 return 1 256 return 1
260 else: 257 else:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 browser = start_browser(browser_name, executable_path, html_out) 388 browser = start_browser(browser_name, executable_path, html_out)
392 389
393 try: 390 try:
394 output = run_test_in_browser(browser, html_out, timeout, mode, refresh) 391 output = run_test_in_browser(browser, html_out, timeout, mode, refresh)
395 return report_results(mode, output, browser) 392 return report_results(mode, output, browser)
396 finally: 393 finally:
397 close_browser(browser) 394 close_browser(browser)
398 395
399 if __name__ == "__main__": 396 if __name__ == "__main__":
400 sys.exit(main(sys.argv)) 397 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698