82c1d41b21529ff07dc4fbfdbd174d65ae645a4f
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / webdriver_benchmark_runner.py
1 #!/usr/bin/env python
2
3 import json
4 import logging
5
6 from benchmark_runner import BenchmarkRunner
7
8
9 _log = logging.getLogger(__name__)
10
11
12 class WebDriverBenchmarkRunner(BenchmarkRunner):
13     name = 'webdriver'
14
15     def _get_result(self, driver):
16         result = driver.execute_script("return window.webdriver_results")
17         return result
18
19     def _run_one_test(self, web_root, test_file):
20         from webkitpy.thirdparty.autoinstalled.selenium.webdriver.support.ui import WebDriverWait
21         result = None
22         try:
23             url = 'file://{root}/{plan_name}/{test_file}'.format(root=web_root, plan_name=self._plan_name, test_file=test_file)
24             driver = self._browser_driver.launch_driver(url, self._plan['options'], self._build_dir)
25             _log.info('Waiting on results from web browser')
26             result = WebDriverWait(driver, self._plan['timeout'], poll_frequency=1.0).until(self._get_result)
27         finally:
28             self._browser_driver.close_browsers()
29
30         return json.loads(result)