OLD | NEW |
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 def print_server_error(): | 143 def print_server_error(): |
144 """Provide the user an informative error message if we attempt to connect to | 144 """Provide the user an informative error message if we attempt to connect to |
145 the Selenium remote control server, but cannot access it. Then exit the | 145 the Selenium remote control server, but cannot access it. Then exit the |
146 program.""" | 146 program.""" |
147 print ('ERROR: Could not connect to Selenium RC server. Are you running' | 147 print ('ERROR: Could not connect to Selenium RC server. Are you running' |
148 ' java -jar tools/testing/selenium-server-standalone-*.jar? If not, ' | 148 ' java -jar tools/testing/selenium-server-standalone-*.jar? If not, ' |
149 'start it before running this test.') | 149 'start it before running this test.') |
150 sys.exit(1) | 150 sys.exit(1) |
151 | 151 |
152 def start_browser(browser, executable_path, html_out): | 152 def start_browser(browser, executable_path, html_out): |
153 if browser == 'chrome': | 153 if browser == 'chrome' or browser == 'dartium': |
154 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to | 154 # Note: you need ChromeDriver *in your path* to run Chrome, in addition to |
155 # installing Chrome. Also note that the build bot runs have a different path | 155 # installing Chrome. Also note that the build bot runs have a different path |
156 # from a normal user -- check the build logs. | 156 # from a normal user -- check the build logs. |
157 return selenium.webdriver.Chrome() | |
158 elif browser == 'dartium': | |
159 script_dir = os.path.dirname(os.path.abspath(__file__)) | |
160 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests', | |
161 'dartium') | |
162 options = selenium.webdriver.chrome.options.Options() | 157 options = selenium.webdriver.chrome.options.Options() |
163 # enable ShadowDOM and style scoped for Dartium | 158 if browser == 'dartium': |
164 options.add_argument('--enable-shadow-dom') | 159 script_dir = os.path.dirname(os.path.abspath(__file__)) |
165 options.add_argument('--enable-style-scoped') | 160 dartium_dir = os.path.join(script_dir, '..', '..', 'client', 'tests', |
166 if executable_path is not None: | 161 'dartium') |
167 options.binary_location = executable_path | 162 # enable ShadowDOM and style scoped for Dartium |
168 elif platform.system() == 'Windows': | 163 options.add_argument('--enable-shadow-dom') |
169 options.binary_location = os.path.join(dartium_dir, 'chrome.exe') | 164 options.add_argument('--enable-style-scoped') |
170 elif platform.system() == 'Darwin': | 165 if executable_path is not None: |
171 options.binary_location = os.path.join(dartium_dir, 'Chromium.app', | 166 options.binary_location = executable_path |
172 'Contents', 'MacOS', 'Chromium') | 167 elif platform.system() == 'Windows': |
173 else: | 168 options.binary_location = os.path.join(dartium_dir, 'chrome.exe') |
174 options.binary_location = os.path.join(dartium_dir, 'chrome') | 169 elif platform.system() == 'Darwin': |
| 170 options.binary_location = os.path.join(dartium_dir, 'Chromium.app', |
| 171 'Contents', 'MacOS', 'Chromium') |
| 172 else: |
| 173 options.binary_location = os.path.join(dartium_dir, 'chrome') |
175 return selenium.webdriver.Chrome(chrome_options=options) | 174 return selenium.webdriver.Chrome(chrome_options=options) |
176 elif browser == 'ff': | 175 elif browser == 'ff': |
177 script_dir = os.path.dirname(os.path.abspath(__file__)) | 176 script_dir = os.path.dirname(os.path.abspath(__file__)) |
178 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile() | 177 profile = selenium.webdriver.firefox.firefox_profile.FirefoxProfile() |
179 profile.set_preference('dom.max_script_run_time', 0) | 178 profile.set_preference('dom.max_script_run_time', 0) |
180 profile.set_preference('dom.max_chrome_script_run_time', 0) | 179 profile.set_preference('dom.max_chrome_script_run_time', 0) |
181 profile.set_preference('app.update.auto', True) | 180 profile.set_preference('app.update.auto', True) |
182 profile.set_preference('app.update.enabled', True) | 181 profile.set_preference('app.update.enabled', True) |
183 return selenium.webdriver.Firefox(firefox_profile=profile) | 182 return selenium.webdriver.Firefox(firefox_profile=profile) |
184 elif ((browser == 'ie9' or browser == 'ie10') and | 183 elif ((browser == 'ie9' or browser == 'ie10') and |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 browser = start_browser(browser_name, executable_path, html_out) | 365 browser = start_browser(browser_name, executable_path, html_out) |
367 | 366 |
368 try: | 367 try: |
369 output = run_test_in_browser(browser, html_out, timeout, mode, refresh) | 368 output = run_test_in_browser(browser, html_out, timeout, mode, refresh) |
370 return report_results(mode, output, browser) | 369 return report_results(mode, output, browser) |
371 finally: | 370 finally: |
372 close_browser(browser) | 371 close_browser(browser) |
373 | 372 |
374 if __name__ == "__main__": | 373 if __name__ == "__main__": |
375 sys.exit(main(sys.argv)) | 374 sys.exit(main(sys.argv)) |
OLD | NEW |