Changeset 219850 in webkit


Ignore:
Timestamp:
Jul 24, 2017 5:40:52 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Add WebDriver support in browser driver part of BenchmarkRunner
https://bugs.webkit.org/show_bug.cgi?id=174445

Patch by Matthew Stewart <matthew_r_stewart@apple.com> on 2017-07-24
Reviewed by Stephanie Lewis.

Adds a launch_driver function to each BrowserDriver subclass. This
function sets up the arguments for the webdriver and launches the
webdriver specific to that browser.

  • Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:

(BrowserDriver.launch_webdriver):
(BrowserDriver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py:

(LinuxBrowserDriver.launch_webdriver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py:

(LinuxChromeDriver.launch_url):
(LinuxChromeDriver):
(LinuxChromeDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py:

(EpiphanyBrowserDriver.launch_url):
(EpiphanyBrowserDriver):
(EpiphanyBrowserDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py:

(LinuxFirefoxDriver):
(LinuxFirefoxDriver.launch_url):
(LinuxFirefoxDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py:

(GTKMiniBrowserDriver.launch_url):
(GTKMiniBrowserDriver):
(GTKMiniBrowserDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:

(OSXBrowserDriver._launch_webdriver):
(OSXBrowserDriver):
(OSXBrowserDriver._screen_size):
(OSXBrowserDriver._insert_url):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:

(OSXChromeDriver):
(OSXChromeDriver.launch_url):
(OSXChromeDriver.launch_driver):
(OSXChromeCanaryDriver):
(OSXChromeCanaryDriver.launch_url):
(OSXChromeCanaryDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:

(OSXFirefoxDriver):
(OSXFirefoxDriver.launch_url):
(OSXFirefoxDriver.launch_driver):
(OSXFirefoxNightlyDriver):
(OSXFirefoxNightlyDriver.launch_url):
(OSXFirefoxNightlyDriver.launch_driver):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:

(OSXSafariDriver.launch_driver):

Location:
trunk/Tools
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r219836 r219850  
     12017-07-24  Matthew Stewart  <matthew_r_stewart@apple.com>
     2
     3        Add WebDriver support in browser driver part of BenchmarkRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=174445
     5
     6        Reviewed by Stephanie Lewis.
     7
     8        Adds a launch_driver function to each BrowserDriver subclass. This
     9        function sets up the arguments for the webdriver and launches the
     10        webdriver specific to that browser.
     11
     12        * Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:
     13        (BrowserDriver.launch_webdriver):
     14        (BrowserDriver):
     15        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py:
     16        (LinuxBrowserDriver.launch_webdriver):
     17        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py:
     18        (LinuxChromeDriver.launch_url):
     19        (LinuxChromeDriver):
     20        (LinuxChromeDriver.launch_driver):
     21        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py:
     22        (EpiphanyBrowserDriver.launch_url):
     23        (EpiphanyBrowserDriver):
     24        (EpiphanyBrowserDriver.launch_driver):
     25        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py:
     26        (LinuxFirefoxDriver):
     27        (LinuxFirefoxDriver.launch_url):
     28        (LinuxFirefoxDriver.launch_driver):
     29        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py:
     30        (GTKMiniBrowserDriver.launch_url):
     31        (GTKMiniBrowserDriver):
     32        (GTKMiniBrowserDriver.launch_driver):
     33        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
     34        (OSXBrowserDriver._launch_webdriver):
     35        (OSXBrowserDriver):
     36        (OSXBrowserDriver._screen_size):
     37        (OSXBrowserDriver._insert_url):
     38        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
     39        (OSXChromeDriver):
     40        (OSXChromeDriver.launch_url):
     41        (OSXChromeDriver.launch_driver):
     42        (OSXChromeCanaryDriver):
     43        (OSXChromeCanaryDriver.launch_url):
     44        (OSXChromeCanaryDriver.launch_driver):
     45        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:
     46        (OSXFirefoxDriver):
     47        (OSXFirefoxDriver.launch_url):
     48        (OSXFirefoxDriver.launch_driver):
     49        (OSXFirefoxNightlyDriver):
     50        (OSXFirefoxNightlyDriver.launch_url):
     51        (OSXFirefoxNightlyDriver.launch_driver):
     52        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
     53        (OSXSafariDriver.launch_driver):
     54
    1552017-07-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    256
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py

    r211549 r219850  
    1919
    2020    @abstractmethod
     21    def launch_webdriver(self, url, driver):
     22        pass
     23
     24    @abstractmethod
    2125    def add_additional_results(self, test_url, results):
    2226        return results
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py

    r211549 r219850  
    9898                                                 stderr=subprocess.STDOUT)
    9999
     100    def launch_webdriver(self, url, driver):
     101        _log.info('Launching "%s" with url "%s"' % (driver.name, url))
     102        driver.get(url)
     103
    100104    def _get_first_executable_path_from_list(self, searchlist):
    101105        searchpath = [os.path.curdir] + os.environ['PATH'].split(os.pathsep)
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py

    r209090 r219850  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
     27import os
     28
    2729from linux_browser_driver import LinuxBrowserDriver
     30from selenium import webdriver
     31from selenium.webdriver.chrome.options import Options
    2832
    2933
     
    3640                                   '--homepage', url]
    3741        super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path)
     42
     43    def launch_driver(self, url, options, browser_build_path):
     44        options = Options()
     45        options.add_argument("--disable-web-security")
     46        options.add_argument("--user-data-dir")
     47        options.add_argument("--disable-extensions")
     48        options.add_argument("--start-maximized")
     49        if browser_build_path:
     50            binary_path = os.path.join(browser_build_path, 'chromium-browser')
     51            options.binary_location = binary_path
     52        driver = webdriver.Chrome(chrome_options=options)
     53        super(LinuxChromeDriver, self).launch_webdriver(url, driver)
     54        return driver
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py

    r209090 r219850  
    3737                                   url]
    3838        super(EpiphanyBrowserDriver, self).launch_url(url, options, browser_build_path)
     39
     40    def launch_driver(self, url, options, browser_build_path):
     41        raise ValueError("Browser {browser} is not available with webdriver".format(browser=self.browser_name))
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py

    r209090 r219850  
    2525# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2626
     27import os
     28
    2729from linux_browser_driver import LinuxBrowserDriver
     30from selenium import webdriver
     31from selenium.webdriver.firefox.options import Options
    2832
    2933
    3034class LinuxFirefoxDriver(LinuxBrowserDriver):
    3135    browser_name = 'firefox'
    32     process_search_list = ['firefox']
     36    process_search_list = ['firefox', 'firefox-bin']
    3337
    3438    def launch_url(self, url, options, browser_build_path):
     
    3842                                   url]
    3943        super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path)
     44
     45    def launch_driver(self, url, options, browser_build_path):
     46        options = Options()
     47        if browser_build_path:
     48            binary_path = os.path.join(browser_build_path, 'firefox-bin')
     49            options.binary_location = binary_path
     50        driver = webdriver.Firefox(firefox_options=options)
     51        super(LinuxFirefoxDriver, self).launch_webdriver(url, driver)
     52        return driver
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py

    r209090 r219850  
    3939        self._browser_arguments.append(url)
    4040        super(GTKMiniBrowserDriver, self).launch_url(url, options, browser_build_path)
     41
     42    def launch_driver(self, url, options, browser_build_path):
     43        raise ValueError("Browser {browser} is not available with webdriver".format(browser=self.browser_name))
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py

    r211549 r219850  
    4444
    4545    @classmethod
     46    def _launch_webdriver(cls, url, driver):
     47        _log.info('Launching "%s" with url "%s"' % (driver.name, url))
     48        driver.get(url)
     49
     50    @classmethod
    4651    def _terminate_processes(cls, process_name):
    4752        _log.info('Closing all processes with name %s' % process_name)
     
    5863        from AppKit import NSScreen
    5964        return NSScreen.mainScreen().frame().size
     65
     66    @classmethod
     67    def _insert_url(cls, args, pos, url):
     68        temp_args = args[:]
     69        temp_args.insert(pos, url)
     70        return temp_args
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py

    r199805 r219850  
    77
    88from osx_browser_driver import OSXBrowserDriver
     9from selenium import webdriver
     10from selenium.webdriver.chrome.options import Options
    911
    1012
    1113_log = logging.getLogger(__name__)
     14window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height))
     15args = ['--args', '--homepage', window_size_arg]
     16chrome_options = Options()
     17chrome_options.add_argument("--disable-web-security")
     18chrome_options.add_argument("--user-data-dir")
     19chrome_options.add_argument("--disable-extensions")
     20chrome_options.add_argument(window_size_arg)
    1221
    1322
     
    1524    process_name = 'Google Chrome'
    1625    browser_name = 'chrome'
     26    app_name = 'Google Chrome.app'
    1727
    1828    def launch_url(self, url, options, browser_build_path):
    19         self._launch_process(build_dir=browser_build_path, app_name='Google Chrome.app', url=url, args=['--args', '--homepage', url, '--window-size={width},{height}'.format(width=int(self._screen_size().width), height=int(self._screen_size().height))])
     29        args_with_url = self._insert_url(args, 2, url)
     30        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     31
     32    def launch_driver(self, url, options, browser_build_path):
     33        if browser_build_path:
     34            app_path = os.path.join(browser_build_path, self.app_name)
     35            binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
     36            chrome_options.binary_location = binary_path
     37        driver = webdriver.Chrome(chrome_options=chrome_options)
     38        self._launch_webdriver(url=url, driver=driver)
     39        return driver
    2040
    2141
     
    2343    process_name = 'Google Chrome Canary'
    2444    browser_name = 'chrome-canary'
     45    app_name = 'Google Chrome Canary.app'
    2546
    2647    def launch_url(self, url, options, browser_build_path):
    27         self._launch_process(build_dir=browser_build_path, app_name='Google Chrome Canary.app', url=url, args=['--args', '--homepage', url, '--window-size={width},{height}'.format(width=int(self._screen_size().width), height=int(self._screen_size().height))])
     48        args_with_url = self._insert_url(args, 2, url)
     49        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     50
     51    def launch_driver(self, url, options, browser_build_path):
     52        if not browser_build_path:
     53            browser_build_path = '/Applications/'
     54        app_path = os.path.join(browser_build_path, self.app_name)
     55        binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
     56        chrome_options.binary_location = binary_path
     57        driver = webdriver.Chrome(chrome_options=chrome_options)
     58        self._launch_webdriver(url=url, driver=driver)
     59        return driver
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py

    r199805 r219850  
    77
    88from osx_browser_driver import OSXBrowserDriver
     9from selenium import webdriver
     10from selenium.webdriver.firefox.options import Options
    911
    1012
    1113_log = logging.getLogger(__name__)
     14
     15args = ['--args', '-width', str(int(OSXBrowserDriver._screen_size().width)), '-height', str(int(OSXBrowserDriver._screen_size().height))]
     16firefox_options = Options()
    1217
    1318
     
    1520    process_name = 'firefox'
    1621    browser_name = 'firefox'
     22    app_name = 'Firefox.app'
    1723
    1824    def launch_url(self, url, options, browser_build_path):
    19         self._launch_process(build_dir=browser_build_path, app_name='Firefox.app', url=url, args=[url, '--args', '-width', str(int(self._screen_size().width)), '-height', str(int(self._screen_size().height))])
     25        args_with_url = self._insert_url(args, 0, url)
     26        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     27
     28    def launch_driver(self, url, options, browser_build_path):
     29        if browser_build_path:
     30            app_path = os.path.join(browser_build_path, self.app_name)
     31            binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
     32            firefox_options.binary_location = binary_path
     33        driver = webdriver.Firefox(firefox_options=firefox_options)
     34        self._launch_webdriver(url=url, driver=driver)
     35        return driver
    2036
    2137
     
    2339    process_name = 'firefox'
    2440    browser_name = 'firefox-nightly'
     41    app_name = 'FirefoxNightly.app'
    2542
    2643    def launch_url(self, url, options, browser_build_path):
    27         self._launch_process(build_dir=browser_build_path, app_name='FirefoxNightly.app', url=url, args=[url, '--args', '-width', str(int(self._screen_size().width)), '-height', str(int(self._screen_size().height))])
     44        args_with_url = self._insert_url(args, 0, url)
     45        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     46
     47    def launch_driver(self, url, options, browser_build_path):
     48        if not browser_build_path:
     49            browser_build_path = '/Applications/'
     50        app_path = os.path.join(browser_build_path, self.app_name)
     51        binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
     52        firefox_options.binary_location = binary_path
     53        driver = webdriver.Firefox(firefox_options=firefox_options)
     54        self._launch_webdriver(url=url, driver=driver)
     55        return driver
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py

    r211549 r219850  
    99from osx_browser_driver import OSXBrowserDriver
    1010from webkitpy.benchmark_runner.utils import force_remove
     11from selenium import webdriver
    1112
    1213
     
    4647        subprocess.Popen(['open', '-a', args[0], url])
    4748
     49    def launch_driver(self, url, options, browser_build_path):
     50        driver = webdriver.Safari(quiet=False)
     51        self._launch_webdriver(url=url, driver=driver)
     52        return driver
     53
    4854    def close_browsers(self):
    4955        super(OSXSafariDriver, self).close_browsers()
Note: See TracChangeset for help on using the changeset viewer.