-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Spectron version: 3.6.2
Intention
Working on microsoft/vscode#25291, I want to be able to pass --user-data-dir
to my Electron application.
Problem Description
When instantiating Application
and passing --user-data-dir
as an argument to args
, the argument is not passed as native Chrome argument, but as a Spectron one.
new Application({
path: electronPath,
args: [cwd, '--user-data-dir=C:\\test-user-dir'],
env: env
});
This creates a problem that running application instance contains two --user-data-dir
parameters when spawned, where second one is a fake directory created by WebDriver (because --user-data-dir
is not supplied and the one specified in constructor is passed with spectron-arg
prefix to it):
"C:\Executable.exe" c:\cwd --user-data-dir=C:\test-user-dir --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-component-extension=C:\Users\t-mikapo\AppData\Local\Temp\scoped_dir15424_30047\internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12730 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir=C:\Users\t-mikapo\AppData\Local\Temp\scoped_dir15424_28295 data:,
See --user-data-dir=C:\test-user-dir
and --user-data-dir=C:\Users\t-mikapo\AppData\Local\Temp\scoped_dir15424_28295
above.
Verification
To verify that WebDriver does not create a fake directory I've hardcoded var args = ['--user-data-dir=C:\test-user-dir']
here:
https://github.com/electron/spectron/blob/master/lib/application.js#L137.
This resulted in Electron app running with the provided '--user-data-dir' and no fake one was created.
Proposal
Currently Application args
accept arguments that are passed only to executable. Even API says See here for details on the Chrome arguments.
, they are not (or not fully with respect to the scenario above) taken into account.
It would be great to have a separate option on Application
constructor, that allows to pass actual Chrome arguments to it. Please let me know if PR is needed.