Skip to content

Commit

Permalink
benchmarks: gets benchmarks working with safari technology preview
Browse files Browse the repository at this point in the history
Safari Technology Preview requires a handful of customizations, so I created
a different browser type for it.

Change-Id: I4c03de7ffdb52dd20d5f8b0b19c3325e50272565
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3640707
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1002972}
  • Loading branch information
Scott Violet authored and Chromium LUCI CQ committed May 13, 2022
1 parent 2401928 commit f7b0fa9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tools/browserbench-webdriver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The following command line flags are supported for all benchmarks:

- `-b`': The browser to run the benchmark in. The valid options currently are
'chrome' and 'safari'.
'chrome', 'safari', and 'stp'.

- `-e`: Path to the executable for the driver binary.

Expand All @@ -27,6 +27,7 @@ Safari requires enabling remote automation:

1. Enable the developer menu in the Advanced tab of Preferences.
2. Enable 'Remote Automation' via the 'Developer' menu.
3. Run `safaridriver --enable`.

## MotionMark

Expand Down
30 changes: 24 additions & 6 deletions tools/browserbench-webdriver/browserbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import time

DEFAULT_STP_DRIVER_PATH = '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'

class BrowserBench(object):
def __init__(self, name, version):
Expand All @@ -33,16 +34,31 @@ def _CreateChromeDriver(optargs):
chrome = webdriver.Chrome(service=service, options=options)
return chrome

@staticmethod
def _CreateSafariDriver(optargs):
params = {}
if optargs.executable:
params['exexutable_path'] = optargs.executable
if optargs.browser == 'stp':
safari_options = webdriver.safari.options.Options()
safari_options.use_technology_preview = 1
params['desired_capabilities'] = {
'browserName': safari_options.capabilities['browserName']
}
# Stp requires executable_path. If the path is not supplied use the
# typical location.
if not optargs.executable:
params['executable_path'] = DEFAULT_STP_DRIVER_PATH
return webdriver.Safari(**params)

@staticmethod
def _CreateDriver(optargs):
if optargs.browser == 'chrome':
return BrowserBench._CreateChromeDriver(optargs)
elif optargs.browser == 'safari':
elif optargs.browser == 'safari' or optargs.browser == 'stp':
for i in range(0, 10):
try:
return webdriver.Safari(
executable_path=optargs.executable
) if optargs.executable else webdriver.Safari()
return BrowserBench._CreateSafariDriver(optargs)
except selenium.common.exceptions.SessionNotCreatedException as e:
print('Connecting to Safari failed, will try again ', e)
time.sleep(5)
Expand Down Expand Up @@ -114,11 +130,13 @@ def Run(self):
parser.add_option('-b',
'--browser',
dest='browser',
help='The browser to use to run MotionMark in.')
help="""The browser to use. One of chrome, safari, or stp
(Safari Technology Preview).""")
parser.add_option('-e',
'--executable-path',
dest='executable',
help='Path to the executable to the driver binary.')
help="""Path to the executable to the driver binary. For
safari this is the path to safaridriver.""")
parser.add_option('-a',
'--arguments',
dest='arguments',
Expand Down

0 comments on commit f7b0fa9

Please sign in to comment.