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

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

Issue 10014004: Preliminary selenium support for Dartium (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
« tools/get_drt.py ('K') | « tools/get_drt.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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 CONFIGURATIONS = { 68 CONFIGURATIONS = {
69 'correctness': correctness_test_done, 69 'correctness': correctness_test_done,
70 'perf': perf_test_done, 70 'perf': perf_test_done,
71 'dromaeo': dromaeo_test_done 71 'dromaeo': dromaeo_test_done
72 } 72 }
73 73
74 def run_test_in_browser(browser, html_out, timeout, mode): 74 def run_test_in_browser(browser, html_out, timeout, mode):
75 """Run the desired test in the browser using Selenium 2.0 WebDriver syntax, 75 """Run the desired test in the browser using Selenium 2.0 WebDriver syntax,
76 and wait for the test to complete. This is the newer syntax, that currently 76 and wait for the test to complete. This is the newer syntax, that currently
77 supports Firefox, Chrome, IE, Opera (and some mobile browsers).""" 77 supports Firefox, Chrome, IE, Opera (and some mobile browsers)."""
78
78 if isinstance(browser, selenium.selenium): 79 if isinstance(browser, selenium.selenium):
79 return run_test_in_browser_selenium_rc(browser, html_out, timeout, mode) 80 return run_test_in_browser_selenium_rc(browser, html_out, timeout, mode)
80 81
81 browser.get("file://" + html_out) 82 browser.get("file://" + html_out)
82 source = '' 83 source = ''
83 try: 84 try:
84 test_done = CONFIGURATIONS[mode] 85 test_done = CONFIGURATIONS[mode]
85 element = WebDriverWait(browser, float(timeout)).until( 86 element = WebDriverWait(browser, float(timeout)).until(
86 lambda driver: test_done(driver.page_source)) 87 lambda driver: test_done(driver.page_source))
87 source = browser.page_source 88 source = browser.page_source
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 action = 'store', default='correctness') 125 action = 'store', default='correctness')
125 args, ignored = parser.parse_args(args=args) 126 args, ignored = parser.parse_args(args=args)
126 return args.out, args.browser, args.timeout, args.mode 127 return args.out, args.browser, args.timeout, args.mode
127 128
128 def start_browser(browser, html_out): 129 def start_browser(browser, html_out):
129 if browser == 'chrome': 130 if browser == 'chrome':
130 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to 131 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to
131 # installing Chrome. Also note that the build bot runs have a different path 132 # installing Chrome. Also note that the build bot runs have a different path
132 # from a normal user -- check the build logs. 133 # from a normal user -- check the build logs.
133 return selenium.webdriver.Chrome() 134 return selenium.webdriver.Chrome()
135 elif browser == 'dartium':
136 script_dir = os.path.dirname(os.path.abspath(__file__))
137 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests',
138 'dartium')
139 options = selenium.webdriver.chrome.options.Options()
140 if platform.system() == 'Windows':
141 options.binary_location = os.path.join(dartium_dir, 'chrome.exe')
142 elif platform.system() == 'Darwin':
143 options.binary_location = os.path.join(dartium_dir, 'Chromium.app',
144 'Contents', 'MacOS', 'Chromium')
145 else:
146 options.binary_location = os.path.join(dartium_dir, 'chrome')
147 return selenium.webdriver.Chrome(chrome_options=options)
134 elif browser == 'ff': 148 elif browser == 'ff':
135 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile() 149 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile()
136 profile.set_preference('dom.max_script_run_time', 0) 150 profile.set_preference('dom.max_script_run_time', 0)
137 profile.set_preference('dom.max_chrome_script_run_time', 0) 151 profile.set_preference('dom.max_chrome_script_run_time', 0)
138 return selenium.webdriver.Firefox(firefox_profile=profile) 152 return selenium.webdriver.Firefox(firefox_profile=profile)
139 elif browser == 'ie' and platform.system() == 'Windows': 153 elif browser == 'ie' and platform.system() == 'Windows':
140 return selenium.webdriver.Ie() 154 return selenium.webdriver.Ie()
141 elif browser == 'safari' and platform.system() == 'Darwin': 155 elif browser == 'safari' and platform.system() == 'Darwin':
142 # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the 156 # TODO(efortuna): Ensure our preferences (no pop-up blocking) file is the
143 # same (Safari auto-deletes when it has too many "crashes," or in our case, 157 # same (Safari auto-deletes when it has too many "crashes," or in our case,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 browser = start_browser(browser_name, html_out) 296 browser = start_browser(browser_name, html_out)
283 297
284 try: 298 try:
285 output = run_test_in_browser(browser, html_out, timeout, mode) 299 output = run_test_in_browser(browser, html_out, timeout, mode)
286 return report_results(mode, output) 300 return report_results(mode, output)
287 finally: 301 finally:
288 close_browser(browser) 302 close_browser(browser)
289 303
290 if __name__ == "__main__": 304 if __name__ == "__main__":
291 sys.exit(main(sys.argv)) 305 sys.exit(main(sys.argv))
OLDNEW
« tools/get_drt.py ('K') | « tools/get_drt.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698