6 from osx_browser_driver import OSXBrowserDriver
9 _log = logging.getLogger(__name__)
10 window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height))
11 args = ['--args', '--homepage', window_size_arg]
13 class OSXChromeDriver(OSXBrowserDriver):
14 process_name = 'Google Chrome'
15 browser_name = 'chrome'
16 app_name = 'Google Chrome.app'
18 def launch_url(self, url, options, browser_build_path):
19 args_with_url = self._insert_url(args, 2, url)
20 self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
22 def launch_driver(self, url, options, browser_build_path):
23 chrome_options = create_chrome_options()
24 if browser_build_path:
25 app_path = os.path.join(browser_build_path, self.app_name)
26 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
27 chrome_options.binary_location = binary_path
28 driver_executable = self.webdriver_binary_path
29 from webkitpy.thirdparty.autoinstalled.selenium import webdriver
30 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
31 self._launch_webdriver(url=url, driver=driver)
35 class OSXChromeCanaryDriver(OSXBrowserDriver):
36 process_name = 'Google Chrome Canary'
37 browser_name = 'chrome-canary'
38 app_name = 'Google Chrome Canary.app'
40 def launch_url(self, url, options, browser_build_path):
41 args_with_url = self._insert_url(args, 2, url)
42 self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
44 def launch_driver(self, url, options, browser_build_path):
45 chrome_options = create_chrome_options()
46 if not browser_build_path:
47 browser_build_path = '/Applications/'
48 app_path = os.path.join(browser_build_path, self.app_name)
49 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
50 chrome_options.binary_location = binary_path
51 driver_executable = self.webdriver_binary_path
52 from webkitpy.thirdparty.autoinstalled.selenium import webdriver
53 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
54 self._launch_webdriver(url=url, driver=driver)
58 def create_chrome_options():
59 from webkitpy.thirdparty.autoinstalled.selenium.webdriver.chrome.options import Options
60 chrome_options = Options()
61 chrome_options.add_argument("--disable-web-security")
62 chrome_options.add_argument("--user-data-dir")
63 chrome_options.add_argument("--disable-extensions")
64 chrome_options.add_argument(window_size_arg)