From 517db0747c9fbb3fd3943295d0100befab35da47 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 25 Jul 2017 04:36:46 +0000 Subject: [PATCH] Fix BenchmarkRunner to only import selenium when needed https://bugs.webkit.org/show_bug.cgi?id=174808 Patch by Matthew Stewart on 2017-07-24 Reviewed by Stephanie Lewis. * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py: (LinuxChromeDriver.launch_driver): * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py: (LinuxFirefoxDriver.launch_driver): * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py: (OSXChromeDriver.launch_driver): (OSXChromeCanaryDriver.launch_driver): (create_chrome_options): * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py: (OSXFirefoxDriver.launch_driver): (OSXFirefoxNightlyDriver.launch_driver): * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py: (OSXSafariDriver.launch_driver): * Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py: (WebDriverBenchmarkRunner._run_one_test): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219860 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 23 +++++++++++++++++++ .../browser_driver/linux_chrome_driver.py | 4 ++-- .../browser_driver/linux_firefox_driver.py | 4 ++-- .../browser_driver/osx_chrome_driver.py | 22 +++++++++++------- .../browser_driver/osx_firefox_driver.py | 9 +++++--- .../browser_driver/osx_safari_driver.py | 2 +- .../webdriver_benchmark_runner.py | 2 +- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 20c03481149a..67a584fe1edc 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,26 @@ +2017-07-24 Matthew Stewart + + Fix BenchmarkRunner to only import selenium when needed + https://bugs.webkit.org/show_bug.cgi?id=174808 + + Reviewed by Stephanie Lewis. + + * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py: + (LinuxChromeDriver.launch_driver): + * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py: + (LinuxFirefoxDriver.launch_driver): + * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py: + (OSXChromeDriver.launch_driver): + (OSXChromeCanaryDriver.launch_driver): + (create_chrome_options): + * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py: + (OSXFirefoxDriver.launch_driver): + (OSXFirefoxNightlyDriver.launch_driver): + * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py: + (OSXSafariDriver.launch_driver): + * Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py: + (WebDriverBenchmarkRunner._run_one_test): + 2017-07-23 Darin Adler More NeverDestroyed and related cleanup diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py index 60c0ffff6785..6b873f5f7f63 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py @@ -27,8 +27,6 @@ import os from linux_browser_driver import LinuxBrowserDriver -from selenium import webdriver -from selenium.webdriver.chrome.options import Options class LinuxChromeDriver(LinuxBrowserDriver): @@ -41,6 +39,7 @@ class LinuxChromeDriver(LinuxBrowserDriver): super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path) def launch_driver(self, url, options, browser_build_path): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.chrome.options import Options options = Options() options.add_argument("--disable-web-security") options.add_argument("--user-data-dir") @@ -50,6 +49,7 @@ class LinuxChromeDriver(LinuxBrowserDriver): binary_path = os.path.join(browser_build_path, 'chromium-browser') options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Chrome(chrome_options=options, executable_path=driver_executable) super(LinuxChromeDriver, self).launch_webdriver(url, driver) return driver diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py index 6bea17281783..dee975456e5c 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py @@ -27,8 +27,6 @@ import os from linux_browser_driver import LinuxBrowserDriver -from selenium import webdriver -from selenium.webdriver.firefox.options import Options class LinuxFirefoxDriver(LinuxBrowserDriver): @@ -43,11 +41,13 @@ class LinuxFirefoxDriver(LinuxBrowserDriver): super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path) def launch_driver(self, url, options, browser_build_path): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options options = Options() if browser_build_path: binary_path = os.path.join(browser_build_path, 'firefox-bin') options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Firefox(firefox_options=options, executable_path=driver_executable) super(LinuxFirefoxDriver, self).launch_webdriver(url, driver) return driver diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py index 013b1006686e..c67066bbaffa 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py @@ -4,19 +4,11 @@ import logging import os from osx_browser_driver import OSXBrowserDriver -from selenium import webdriver -from selenium.webdriver.chrome.options import Options _log = logging.getLogger(__name__) window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height)) args = ['--args', '--homepage', window_size_arg] -chrome_options = Options() -chrome_options.add_argument("--disable-web-security") -chrome_options.add_argument("--user-data-dir") -chrome_options.add_argument("--disable-extensions") -chrome_options.add_argument(window_size_arg) - class OSXChromeDriver(OSXBrowserDriver): process_name = 'Google Chrome' @@ -28,11 +20,13 @@ class OSXChromeDriver(OSXBrowserDriver): self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url) def launch_driver(self, url, options, browser_build_path): + chrome_options = create_chrome_options() if browser_build_path: app_path = os.path.join(browser_build_path, self.app_name) binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) chrome_options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable) self._launch_webdriver(url=url, driver=driver) return driver @@ -48,12 +42,24 @@ class OSXChromeCanaryDriver(OSXBrowserDriver): self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url) def launch_driver(self, url, options, browser_build_path): + chrome_options = create_chrome_options() if not browser_build_path: browser_build_path = '/Applications/' app_path = os.path.join(browser_build_path, self.app_name) binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) chrome_options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable) self._launch_webdriver(url=url, driver=driver) return driver + + +def create_chrome_options(): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.chrome.options import Options + chrome_options = Options() + chrome_options.add_argument("--disable-web-security") + chrome_options.add_argument("--user-data-dir") + chrome_options.add_argument("--disable-extensions") + chrome_options.add_argument(window_size_arg) + return chrome_options diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py index 67afe839a4b5..54a056b0fe62 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py @@ -4,14 +4,11 @@ import logging import os from osx_browser_driver import OSXBrowserDriver -from selenium import webdriver -from selenium.webdriver.firefox.options import Options _log = logging.getLogger(__name__) args = ['--args', '-width', str(int(OSXBrowserDriver._screen_size().width)), '-height', str(int(OSXBrowserDriver._screen_size().height))] -firefox_options = Options() class OSXFirefoxDriver(OSXBrowserDriver): @@ -24,11 +21,14 @@ class OSXFirefoxDriver(OSXBrowserDriver): self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url) def launch_driver(self, url, options, browser_build_path): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options + firefox_options = Options() if browser_build_path: app_path = os.path.join(browser_build_path, self.app_name) binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) firefox_options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable) self._launch_webdriver(url=url, driver=driver) return driver @@ -44,12 +44,15 @@ class OSXFirefoxNightlyDriver(OSXBrowserDriver): self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url) def launch_driver(self, url, options, browser_build_path): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.firefox.options import Options + firefox_options = Options() if not browser_build_path: browser_build_path = '/Applications/' app_path = os.path.join(browser_build_path, self.app_name) binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name) firefox_options.binary_location = binary_path driver_executable = self.webdriver_binary_path + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable) self._launch_webdriver(url=url, driver=driver) return driver diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py index 89a2f06d4971..c6a0c4a3f78f 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py @@ -7,7 +7,6 @@ import time from osx_browser_driver import OSXBrowserDriver from webkitpy.benchmark_runner.utils import force_remove -from selenium import webdriver _log = logging.getLogger(__name__) @@ -46,6 +45,7 @@ class OSXSafariDriver(OSXBrowserDriver): subprocess.Popen(['open', '-a', args[0], url]) def launch_driver(self, url, options, browser_build_path): + from webkitpy.thirdparty.autoinstalled.selenium import webdriver driver = webdriver.Safari(quiet=False) self._launch_webdriver(url=url, driver=driver) return driver diff --git a/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py b/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py index 1eb53f9966fd..82c1d41b2152 100644 --- a/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py +++ b/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py @@ -4,7 +4,6 @@ import json import logging from benchmark_runner import BenchmarkRunner -from selenium.webdriver.support.ui import WebDriverWait _log = logging.getLogger(__name__) @@ -18,6 +17,7 @@ class WebDriverBenchmarkRunner(BenchmarkRunner): return result def _run_one_test(self, web_root, test_file): + from webkitpy.thirdparty.autoinstalled.selenium.webdriver.support.ui import WebDriverWait result = None try: url = 'file://{root}/{plan_name}/{test_file}'.format(root=web_root, plan_name=self._plan_name, test_file=test_file) -- 2.36.0