Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS]Modify: Fixes adding command-line switches for ieOptions #8189

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- setEdgePath
- setEdgeChromium
- setScrollBehavior
- Supports adding multiple command-line switches using options.addArguments()

### API Changes

Expand Down
4 changes: 2 additions & 2 deletions javascript/node/selenium-webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
* .setFirefoxOptions(options)
* .build();
*
* On all platforms, you may configrue WebDriver to use a Firefox specific
* On all platforms, you may configure WebDriver to use a Firefox specific
* executable:
*
* let options = new firefox.Options()
Expand All @@ -89,7 +89,7 @@
*
* You may customize the Firefox binary and profile when running against a
* remote Selenium server. Your custom profile will be packaged as a zip and
* transfered to the remote host for use. The profile will be transferred
* transferred to the remote host for use. The profile will be transferred
* _once for each new session_. The performance impact should be minimal if
* you've only configured a few extra browser preferences. If you have a large
* profile with several extensions, you should consider installing it on the
Expand Down
59 changes: 31 additions & 28 deletions javascript/node/selenium-webdriver/ie.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,21 @@ class Options extends Capabilities {
return this;
}

/**
* Specifies command-line switches to use when launching Internet Explorer.
* This is only valid when used with {@link #forceCreateProcessApi}.
*
* @param {...(string|!Array.<string>)} args The arguments to add.
* @return {!Options} A self reference.
*/
addArguments(...args) {
let current = this.get(Key.BROWSER_COMMAND_LINE_SWITCHES) || [];
this.options_[Key.BROWSER_COMMAND_LINE_SWITCHES] = current.concat.apply(current, args);
return this;
}
/**
* Specifies command-line switches to use when launching Internet Explorer.
* This is only valid when used with {@link #forceCreateProcessApi}.
*
* @param {...(string|!Array.<string>)} args The arguments to add.
* @return {!Options} A self reference.
*/

addArguments(...args) {
let current = this.options_[Key.BROWSER_COMMAND_LINE_SWITCHES] || [];
if(typeof current == 'string')
current = current.split(" ");
this.options_[Key.BROWSER_COMMAND_LINE_SWITCHES] = current.concat(args).join(" ");
return this;
}

/**
* Configures whether proxies should be configured on a per-process basis. If
Expand Down Expand Up @@ -388,22 +391,22 @@ function createServiceFromCapabilities(capabilities) {
'ensure it can be found on your system PATH.');
}

var args = [];
if (capabilities.has(Key.HOST)) {
args.push('--host=' + capabilities.get(Key.HOST));
}
if (capabilities.has(Key.LOG_FILE)) {
args.push('--log-file=' + capabilities.get(Key.LOG_FILE));
}
if (capabilities.has(Key.LOG_LEVEL)) {
args.push('--log-level=' + capabilities.get(Key.LOG_LEVEL));
}
if (capabilities.has(Key.EXTRACT_PATH)) {
args.push('--extract-path=' + capabilities.get(Key.EXTRACT_PATH));
}
if (capabilities.get(Key.SILENT)) {
args.push('--silent');
}
var args = [];
if (capabilities.has(Key.HOST)) {
args.push('--host=' + capabilities.get(Key.HOST));
}
if (capabilities.has(Key.LOG_FILE)) {
args.push('--log-file=' + capabilities.get(Key.LOG_FILE));
}
if (capabilities.has(Key.LOG_LEVEL)) {
args.push('--log-level=' + capabilities.get(Key.LOG_LEVEL));
}
if (capabilities.has(Key.EXTRACT_PATH)) {
args.push('--extract-path=' + capabilities.get(Key.EXTRACT_PATH));
}
if (capabilities.get(Key.SILENT)) {
args.push('--silent');
}

var port = portprober.findFreePort();
return new remote.DriverService(exe, {
Expand Down
15 changes: 15 additions & 0 deletions javascript/node/selenium-webdriver/test/ie/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,20 @@ test.suite(function(env) {
assert.equal(caps, ie.Behavior.TOP);
await driver.quit();
});

it('can set multiple command-line switches', async function() {
let options = new ie.Options();
options.addArguments('-k');
options.addArguments('-private');
options.forceCreateProcessApi(true);
driver = await env.builder()
.setIeOptions(options)
.build();

let caps = await driver.getCapabilities();
caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ie.Key.BROWSER_COMMAND_LINE_SWITCHES];
assert.equal(caps, '-k -private');
await driver.quit();
});
});
}, {browsers: ['internet explorer']});