Skip to content

Commit

Permalink
[js] The firefox.Binary class (another holdover from the legacy Firef…
Browse files Browse the repository at this point in the history
…oxDriver)

is overkill for the functionality it provides. Move the only meaningful
functionality (addArguments) to firefox.Options and mark firefox.Binary as
deprecated.
  • Loading branch information
jleyba committed Oct 6, 2017
1 parent 13c8499 commit e4f03b9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### API Changes

* Added `selenium-webdriver/firefox.Options#addArguments()`
* Deprecated `selenium-webdriver/firefox/binary.Binary`
* Removed `selenium-webdriver/firefox.Options#useGeckoDriver()`
* Removed the unused `selenium-webdriver/firefox/profile.decode()`
* Removed methods from `selenium-webdriver/firefox/profile.Profile` that had
Expand Down
3 changes: 3 additions & 0 deletions javascript/node/selenium-webdriver/firefox/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ function installNoFocusLibs(profileDir) {
* `PATH`.
*
* @final
* @deprecated This class will be removed in 4.0. Use the binary management
* functions available on the {@link ./index.Options firefox.Options} class.
*/
class Binary {
/**
Expand Down Expand Up @@ -242,6 +244,7 @@ class Binary {
* Add arguments to the command line used to start Firefox.
* @param {...(string|!Array.<string>)} var_args Either the arguments to add
* as varargs, or the arguments as an array.
* @deprecated Use {@link ./index.Options#addArguments}.
*/
addArguments(var_args) {
for (var i = 0; i < arguments.length; i++) {
Expand Down
24 changes: 24 additions & 0 deletions javascript/node/selenium-webdriver/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,28 @@ class Options {
/** @private {(Binary|Channel|string|null)} */
this.binary_ = null;

/** @private {!Array<string>} */
this.args_ = [];

/** @private {logging.Preferences} */
this.logPrefs_ = null;

/** @private {?capabilities.ProxyConfig} */
this.proxy_ = null;
}

/**
* Specify additional command line arguments that should be used when starting
* the Firefox browser.
*
* @param {...(string|!Array<string>)} args The arguments to include.
* @return {!Options} A self reference.
*/
addArguments(...args) {
this.args_ = this.args_.concat(...args);
return this;
}

/**
* Sets the profile to use. The profile may be specified as a
* {@link Profile} object or as the path to an existing Firefox profile to use
Expand Down Expand Up @@ -230,6 +245,10 @@ class Options {
caps.set(capabilities.Capability.PROXY, this.proxy_);
}

if (this.args_.length) {
firefoxOptions['args'] = this.args_.concat();
}

if (this.binary_) {
if (this.binary_ instanceof Binary) {
let exe = this.binary_.getExe();
Expand All @@ -239,6 +258,11 @@ class Options {

let args = this.binary_.getArguments();
if (args.length) {
if (this.args_.length) {
throw Error(
'You may specify browser arguments with Options.addArguments'
+ ' (preferred) or Binary.addArguments, but not both');
}
firefoxOptions['args'] = args;
}
} else if (this.binary_ instanceof Channel) {
Expand Down

0 comments on commit e4f03b9

Please sign in to comment.