Commit 98981f82 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Log replay support arbitrary ChromeDriver flags

Modify the log replay tool so it can pass arbitrary flags to
ChromeDriver. This is needed for the investigation of an internal
bug, to pass flags such as --disable-build-check.

Bug: b/147732888

Change-Id: Ic38ce33da006965e4861467a37cb0209c9ca9b3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079609
Commit-Queue: John Chen <johnchen@chromium.org>
Auto-Submit: John Chen <johnchen@chromium.org>
Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746190}
parent e9e4cbbd
......@@ -877,7 +877,8 @@ class Replayer(object):
def StartChromeDriverServer(chromedriver_binary,
output_log_path,
devtools_replay_path="",
replayable=False):
replayable=False,
additional_args=None):
chromedriver = util.GetAbsolutePathOfUserPath(chromedriver_binary)
if (not os.path.exists(chromedriver) and
util.GetPlatformName() == "win" and
......@@ -889,7 +890,8 @@ def StartChromeDriverServer(chromedriver_binary,
chromedriver_server = server.Server(chromedriver_binary,
log_path=output_log_path,
devtools_replay_path=devtools_replay_path,
replayable=replayable)
replayable=replayable,
additional_args=additional_args)
return chromedriver_server
......@@ -914,10 +916,12 @@ def _GetCommandLineOptions():
parser.add_option(
"", "--devtools-replay", help="Replay DevTools actions in addition\n"
"to client-side actions")
# TODO(crbug.com/chromedriver/2501)
parser.add_option(
"", "--replayable", help="Generate logs that do not have truncated\n"
"strings so that they can be replayed again.")
parser.add_option(
'', '--additional-args', action='append',
help='Additional arguments to add on ChromeDriver command line')
options, args = parser.parse_args()
if len(args) < 2:
......@@ -940,7 +944,7 @@ def main():
options, args = _GetCommandLineOptions()
devtools_replay_path = args[1] if options.devtools_replay else None
server = StartChromeDriverServer(args[0], options.output_log_path,
devtools_replay_path, options.replayable)
devtools_replay_path, options.replayable, options.additional_args)
input_log_path = util.GetAbsolutePathOfUserPath(args[1])
chrome_binary = (util.GetAbsolutePathOfUserPath(options.chrome)
if options.chrome else None)
......
......@@ -28,7 +28,8 @@ class Server(object):
"""A running ChromeDriver server."""
def __init__(self, exe_path, log_path=None, verbose=True,
replayable=False, devtools_replay_path=None):
replayable=False, devtools_replay_path=None,
additional_args=None):
"""Starts the ChromeDriver server and waits for it to be ready.
Args:
......@@ -37,6 +38,7 @@ class Server(object):
verbose: make the logged data verbose
replayable: don't truncate strings in log to make the session replayable
devtools_replay_path: replay devtools events from the log at this path
additional_args: list of additional arguments to pass to ChromeDriver
Raises:
RuntimeError: if ChromeDriver fails to start
"""
......@@ -58,6 +60,12 @@ class Server(object):
if devtools_replay_path:
chromedriver_args.extend(['--devtools-replay=%s' % devtools_replay_path])
if additional_args:
for arg in additional_args:
if not arg.startswith('--'):
arg = '--' + arg
chromedriver_args.extend([arg])
self._process = subprocess.Popen(chromedriver_args)
self._host = '127.0.0.1'
self._port = port
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment