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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219850
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-07-24 Matthew Stewart <matthew_r_stewart@apple.com>
+
+ Add WebDriver support in browser driver part of BenchmarkRunner
+ https://bugs.webkit.org/show_bug.cgi?id=174445
+
+ 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):
+
2017-07-24 Wenson Hsieh <wenson_hsieh@apple.com>
[Mac WK2] Add an API test to cover r219765 (null dereference in [WKWebView dealloc])
def launch_url(self, url, options, browser_build_path=None):
pass
+ @abstractmethod
+ def launch_webdriver(self, url, driver):
+ pass
+
@abstractmethod
def add_additional_results(self, test_url, results):
return results
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
+ def launch_webdriver(self, url, driver):
+ _log.info('Launching "%s" with url "%s"' % (driver.name, url))
+ driver.get(url)
+
def _get_first_executable_path_from_list(self, searchlist):
searchpath = [os.path.curdir] + os.environ['PATH'].split(os.pathsep)
for program in searchlist:
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
+
from linux_browser_driver import LinuxBrowserDriver
+from selenium import webdriver
+from selenium.webdriver.chrome.options import Options
class LinuxChromeDriver(LinuxBrowserDriver):
self._browser_arguments = ['--temp-profile', '--start-maximized',
'--homepage', url]
super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path)
+
+ def launch_driver(self, url, options, browser_build_path):
+ options = Options()
+ options.add_argument("--disable-web-security")
+ options.add_argument("--user-data-dir")
+ options.add_argument("--disable-extensions")
+ options.add_argument("--start-maximized")
+ if browser_build_path:
+ binary_path = os.path.join(browser_build_path, 'chromium-browser')
+ options.binary_location = binary_path
+ driver = webdriver.Chrome(chrome_options=options)
+ super(LinuxChromeDriver, self).launch_webdriver(url, driver)
+ return driver
'--profile={profile}'.format(profile=self._temp_profiledir),
url]
super(EpiphanyBrowserDriver, self).launch_url(url, options, browser_build_path)
+
+ def launch_driver(self, url, options, browser_build_path):
+ raise ValueError("Browser {browser} is not available with webdriver".format(browser=self.browser_name))
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
+
from linux_browser_driver import LinuxBrowserDriver
+from selenium import webdriver
+from selenium.webdriver.firefox.options import Options
class LinuxFirefoxDriver(LinuxBrowserDriver):
browser_name = 'firefox'
- process_search_list = ['firefox']
+ process_search_list = ['firefox', 'firefox-bin']
def launch_url(self, url, options, browser_build_path):
self._browser_arguments = ['-new-instance', '-profile', self._temp_profiledir,
'-height', str(self._screen_size().height),
url]
super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path)
+
+ def launch_driver(self, url, options, browser_build_path):
+ options = Options()
+ if browser_build_path:
+ binary_path = os.path.join(browser_build_path, 'firefox-bin')
+ options.binary_location = binary_path
+ driver = webdriver.Firefox(firefox_options=options)
+ super(LinuxFirefoxDriver, self).launch_webdriver(url, driver)
+ return driver
self._browser_arguments.append('--geometry={w}x{h}'.format(w=self._screen_size().width, h=self._screen_size().height))
self._browser_arguments.append(url)
super(GTKMiniBrowserDriver, self).launch_url(url, options, browser_build_path)
+
+ def launch_driver(self, url, options, browser_build_path):
+ raise ValueError("Browser {browser} is not available with webdriver".format(browser=self.browser_name))
args = ['open', '-a', app_path] + args
cls._launch_process_with_caffinate(args)
+ @classmethod
+ def _launch_webdriver(cls, url, driver):
+ _log.info('Launching "%s" with url "%s"' % (driver.name, url))
+ driver.get(url)
+
@classmethod
def _terminate_processes(cls, process_name):
_log.info('Closing all processes with name %s' % process_name)
def _screen_size(cls):
from AppKit import NSScreen
return NSScreen.mainScreen().frame().size
+
+ @classmethod
+ def _insert_url(cls, args, pos, url):
+ temp_args = args[:]
+ temp_args.insert(pos, url)
+ return temp_args
import time
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'
browser_name = 'chrome'
+ app_name = 'Google Chrome.app'
def launch_url(self, url, options, browser_build_path):
- 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))])
+ args_with_url = self._insert_url(args, 2, url)
+ 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):
+ 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 = webdriver.Chrome(chrome_options=chrome_options)
+ self._launch_webdriver(url=url, driver=driver)
+ return driver
class OSXChromeCanaryDriver(OSXBrowserDriver):
process_name = 'Google Chrome Canary'
browser_name = 'chrome-canary'
+ app_name = 'Google Chrome Canary.app'
def launch_url(self, url, options, browser_build_path):
- 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))])
+ args_with_url = self._insert_url(args, 2, url)
+ 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):
+ 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 = webdriver.Chrome(chrome_options=chrome_options)
+ self._launch_webdriver(url=url, driver=driver)
+ return driver
import time
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):
process_name = 'firefox'
browser_name = 'firefox'
+ app_name = 'Firefox.app'
def launch_url(self, url, options, browser_build_path):
- 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))])
+ args_with_url = self._insert_url(args, 0, url)
+ 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):
+ 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 = webdriver.Firefox(firefox_options=firefox_options)
+ self._launch_webdriver(url=url, driver=driver)
+ return driver
class OSXFirefoxNightlyDriver(OSXBrowserDriver):
process_name = 'firefox'
browser_name = 'firefox-nightly'
+ app_name = 'FirefoxNightly.app'
def launch_url(self, url, options, browser_build_path):
- 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))])
+ args_with_url = self._insert_url(args, 0, url)
+ 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):
+ 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 = webdriver.Firefox(firefox_options=firefox_options)
+ self._launch_webdriver(url=url, driver=driver)
+ return driver
from osx_browser_driver import OSXBrowserDriver
from webkitpy.benchmark_runner.utils import force_remove
+from selenium import webdriver
_log = logging.getLogger(__name__)
time.sleep(3)
subprocess.Popen(['open', '-a', args[0], url])
+ def launch_driver(self, url, options, browser_build_path):
+ driver = webdriver.Safari(quiet=False)
+ self._launch_webdriver(url=url, driver=driver)
+ return driver
+
def close_browsers(self):
super(OSXSafariDriver, self).close_browsers()
if self._safari_process and self._safari_process.returncode: