67afe839a4b5df6ffd3823550fc6d3151f5b2463
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / browser_driver / osx_firefox_driver.py
1 #!/usr/bin/env python
2
3 import logging
4 import os
5
6 from osx_browser_driver import OSXBrowserDriver
7 from selenium import webdriver
8 from selenium.webdriver.firefox.options import Options
9
10
11 _log = logging.getLogger(__name__)
12
13 args = ['--args', '-width', str(int(OSXBrowserDriver._screen_size().width)), '-height', str(int(OSXBrowserDriver._screen_size().height))]
14 firefox_options = Options()
15
16
17 class OSXFirefoxDriver(OSXBrowserDriver):
18     process_name = 'firefox'
19     browser_name = 'firefox'
20     app_name = 'Firefox.app'
21
22     def launch_url(self, url, options, browser_build_path):
23         args_with_url = self._insert_url(args, 0, url)
24         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
25
26     def launch_driver(self, url, options, browser_build_path):
27         if browser_build_path:
28             app_path = os.path.join(browser_build_path, self.app_name)
29             binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
30             firefox_options.binary_location = binary_path
31         driver_executable = self.webdriver_binary_path
32         driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
33         self._launch_webdriver(url=url, driver=driver)
34         return driver
35
36
37 class OSXFirefoxNightlyDriver(OSXBrowserDriver):
38     process_name = 'firefox'
39     browser_name = 'firefox-nightly'
40     app_name = 'FirefoxNightly.app'
41
42     def launch_url(self, url, options, browser_build_path):
43         args_with_url = self._insert_url(args, 0, url)
44         self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
45
46     def launch_driver(self, url, options, browser_build_path):
47         if not browser_build_path:
48             browser_build_path = '/Applications/'
49         app_path = os.path.join(browser_build_path, self.app_name)
50         binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
51         firefox_options.binary_location = binary_path
52         driver_executable = self.webdriver_binary_path
53         driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
54         self._launch_webdriver(url=url, driver=driver)
55         return driver