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

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")
97 pass
kustermann 2013/01/30 09:52:02 The "pass" should not be necessary here.
ricow1 2013/01/30 09:54:45 removed
90 # If the browser is crashing selenium may not time out. 98 # If the browser is crashing selenium may not time out.
91 # Explicitly catch this case with a python timer. 99 # Explicitly catch this case with a python timer.
92 t = threading.Timer(timeout, pythonTimeout) 100 t = threading.Timer(timeout, pythonTimeout)
93 t.start() 101 t.start()
94 test_done = CONFIGURATIONS[mode] 102 test_done = CONFIGURATIONS[mode]
95 element = WebDriverWait(browser, float(timeout)).until( 103 element = WebDriverWait(browser, float(timeout)).until(
96 lambda driver: test_done(driver.page_source)) 104 lambda driver: test_done(driver.page_source))
97 t.cancel() 105 t.cancel()
98 return browser.page_source 106 return browser.page_source
99 except selenium.common.exceptions.TimeoutException: 107 except selenium.common.exceptions.TimeoutException:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return 238 return
231 if isinstance(browser, selenium.selenium): 239 if isinstance(browser, selenium.selenium):
232 browser.stop() 240 browser.stop()
233 return 241 return
234 242
235 # A timeout exception is thrown if nothing happens within the time limit. 243 # A timeout exception is thrown if nothing happens within the time limit.
236 if (type(browser) is not selenium.webdriver.chrome.webdriver.WebDriver and 244 if (type(browser) is not selenium.webdriver.chrome.webdriver.WebDriver and
237 type(browser) is not selenium.webdriver.ie.webdriver.WebDriver): 245 type(browser) is not selenium.webdriver.ie.webdriver.WebDriver):
238 browser.close() 246 browser.close()
239 247
240 # The builtin quit call will call close on the RemoteDriver which
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() 248 browser.quit()
kustermann 2013/01/30 09:52:02 I think this should be indented one level to the l
ricow1 2013/01/30 09:54:45 good catch
251 249
252 def report_results(mode, source, browser): 250 def report_results(mode, source, browser):
253 # TODO(vsm): Add a failure check for Dromaeo. 251 # TODO(vsm): Add a failure check for Dromaeo.
254 if mode != 'correctness': 252 if mode != 'correctness':
255 # We're running a performance test. 253 # We're running a performance test.
256 print source.encode('utf8') 254 print source.encode('utf8')
257 sys.stdout.flush() 255 sys.stdout.flush()
258 if 'NaN' in source: 256 if 'NaN' in source:
259 return 1 257 return 1
260 else: 258 else:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 browser = start_browser(browser_name, executable_path, html_out) 389 browser = start_browser(browser_name, executable_path, html_out)
392 390
393 try: 391 try:
394 output = run_test_in_browser(browser, html_out, timeout, mode, refresh) 392 output = run_test_in_browser(browser, html_out, timeout, mode, refresh)
395 return report_results(mode, output, browser) 393 return report_results(mode, output, browser)
396 finally: 394 finally:
397 close_browser(browser) 395 close_browser(browser)
398 396
399 if __name__ == "__main__": 397 if __name__ == "__main__":
400 sys.exit(main(sys.argv)) 398 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