Subclass Benchmark Runner script for WebDriver support
[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 from selenium.webdriver.support.ui import WebDriverWait
8
9
10 _log = logging.getLogger(__name__)
11
12
13 class WebDriverBenchmarkRunner(BenchmarkRunner):
14     name = 'webdriver'
15
16     def _get_result(self, driver):
17         result = driver.execute_script("return window.webdriver_results")
18         return result
19
20     def _run_one_test(self, web_root, test_file):
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)