Skip to content

Commit 2b2d5fd

Browse files
committed
[js] Make geckodriver the default for firefox
- Look for geckodriver, not wires Close #2189
1 parent b5165b3 commit 2b2d5fd

File tree

5 files changed

+73
-24
lines changed

5 files changed

+73
-24
lines changed

javascript/node/selenium-webdriver/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
* Internal cleanup replacing uses of managed promises with native promises
1010
* Removed the mandatory use of Firefox Dev Edition, when using Marionette driver
1111
* Fixed timeouts' URL
12+
13+
### API Changes
14+
1215
* `promise.Deferred` is no longer a thenable object.
1316
* `Options#addCookie()` now takes a record object instead of 7 individual
1417
parameters. A TypeError will be thrown if addCookie() is called with invalid
1518
arguments.
1619
* When adding cookies, the desired expiry must be provided as a Date or in
1720
_seconds_ since epoch. When retrieving cookies, the expiration is always
1821
returned in seconds.
22+
* Renamed `firefox.Options#useMarionette` to `firefox.Options#useGeckoDriver`
1923
* Removed deprecated modules:
2024
- `selenium-webdriver/error` (use `selenium-webdriver/lib/error`,\
2125
or the `error` property exported by `selenium-webdriver`)

javascript/node/selenium-webdriver/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ Selenium may be installed via npm with
1010

1111
npm install selenium-webdriver
1212

13-
Out of the box, Selenium includes everything you need to work with Firefox. You
14-
will need to download additional components to work with the other major
15-
browsers. The drivers for Chrome, PhantomJS, Opera, and Microsoft's IE and Edge
16-
web browsers are all standalone executables that should be available on your
17-
[PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29). The SafariDriver
18-
browser extension should be installed in your browser before using Selenium; we
19-
recommend disabling the extension when using the browser without Selenium or
20-
installing the extension in a profile only used for testing.
13+
You will need to download additional components to work with each of the major
14+
browsers. The drivers for Chrome, Firefox, PhantomJS, Opera, and
15+
Microsoft's IE and Edge web browsers are all standalone executables that should
16+
be placed on your system [PATH]. The SafariDriverbrowser extension should be
17+
installed in your browser before using Selenium; we recommend disabling the
18+
extension when using the browser without Selenium or installing the extension in
19+
a profile only used for testing.
20+
21+
> **NOTE:** Mozilla's [geckodriver] is only required for Firefox 47+.
22+
> Everything you need for Firefox 38-46 is included with this package.
2123
2224
| Browser | Component |
2325
| ----------------- | ---------------------------------- |
2426
| Chrome | [chromedriver(.exe)][chrome] |
2527
| Internet Explorer | [IEDriverServer.exe][release] |
2628
| Edge | [MicrosoftWebDriver.msi][edge] |
29+
| Firefox 47+ | [geckodriver(.exe)][geckodriver] |
2730
| PhantomJS | [phantomjs(.exe)][phantomjs] |
2831
| Opera | [operadriver(.exe)][opera] |
2932
| Safari | [SafariDriver.safariextz][release] |
@@ -213,6 +216,7 @@ specific language governing permissions and limitations
213216
under the License.
214217

215218
[LTS]: https://github.com/nodejs/LTS
219+
[PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
216220
[api]: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/
217221
[cla]: http://goo.gl/qC50R
218222
[chrome]: http://chromedriver.storage.googleapis.com/index.html
@@ -221,6 +225,7 @@ under the License.
221225
[opera]: https://github.com/operasoftware/operachromiumdriver/releases
222226
[phantomjs]: http://phantomjs.org/
223227
[edge]: http://go.microsoft.com/fwlink/?LinkId=619687
228+
[geckodriver]: https://github.com/mozilla/geckodriver/releases/
224229
[reduction]: http://www.webkit.org/quality/reduction.html
225230
[release]: http://selenium-release.storage.googleapis.com/index.html
226231
[users]: https://groups.google.com/forum/#!forum/selenium-users

javascript/node/selenium-webdriver/firefox/index.js

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
/**
1919
* @fileoverview Defines the {@linkplain Driver WebDriver} client for Firefox.
20+
* Before using this module, you must download the latest
21+
* [geckodriver release] and ensure it can be found on your system [PATH].
22+
*
2023
* Each FirefoxDriver instance will be created with an anonymous profile,
2124
* ensuring browser historys do not share session data (cookies, history, cache,
2225
* offline storage, etc.)
@@ -90,6 +93,20 @@
9093
* .usingServer('http://127.0.0.1:4444/wd/hub')
9194
* .setFirefoxOptions(options)
9295
* .build();
96+
*
97+
* __Testing Older Versions of Firefox__
98+
*
99+
* To test versions of Firefox prior to Firefox 47, you must disable the use of
100+
* the geckodriver using the {@link Options} class.
101+
*
102+
* var options = new firefox.Options().useGeckoDriver(false);
103+
* var driver = new firefox.Driver(options);
104+
*
105+
* Alternatively, you may disable the geckodriver at runtime by setting the
106+
* environment variable `SELENIUM_MARIONETTE=false`.
107+
*
108+
* [geckodriver release]: https://github.com/mozilla/geckodriver/releases/
109+
* [PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
93110
*/
94111

95112
'use strict';
@@ -158,7 +175,7 @@ class Options {
158175
this.proxy_ = null;
159176

160177
/** @private {boolean} */
161-
this.marionette_ = false;
178+
this.marionette_ = true;
162179
}
163180

164181
/**
@@ -214,12 +231,14 @@ class Options {
214231
}
215232

216233
/**
217-
* Sets whether to use Mozilla's Marionette to drive the browser.
234+
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
235+
* is enabled by default and required for Firefox 47+.
218236
*
219-
* @see https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
237+
* @param {boolean} enable Whether to enable the geckodriver.
238+
* @see https://github.com/mozilla/geckodriver
220239
*/
221-
useMarionette(marionette) {
222-
this.marionette_ = marionette;
240+
useGeckoDriver(enable) {
241+
this.marionette_ = enable;
223242
return this;
224243
}
225244

@@ -247,10 +266,8 @@ class Options {
247266
}
248267
}
249268

250-
// TODO: Wires is the old name of GeckoDriver. Rename to geckodriver, once the
251-
// first renamed version is out at
252-
// https://github.com/mozilla/geckodriver/releases
253-
const GECKO_DRIVER_EXE = process.platform === 'win32' ? 'wires.exe' : 'wires';
269+
const GECKO_DRIVER_EXE =
270+
process.platform === 'win32' ? 'geckodriver.exe' : 'geckodriver';
254271

255272

256273
/**
@@ -263,7 +280,7 @@ function findGeckoDriver() {
263280
throw Error(
264281
'The ' + GECKO_DRIVER_EXE + ' executable could not be found on the current ' +
265282
'PATH. Please download the latest version from ' +
266-
'https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/' +
283+
'https://github.com/mozilla/geckodriver/releases/' +
267284
'WebDriver and ensure it can be found on your PATH.');
268285
}
269286
return exe;
@@ -339,8 +356,14 @@ class Driver extends webdriver.WebDriver {
339356

340357
let serverUrl, onQuit;
341358

342-
if (caps.get(Capability.MARIONETTE)
343-
|| /^1|true$/i.test(process.env['SELENIUM_MARIONETTE'])) {
359+
// Users must now explicitly disable marionette to use the legacy
360+
// FirefoxDriver.
361+
let noMarionette =
362+
caps.get(Capability.MARIONETTE) === false
363+
|| /^0|false$/i.test(process.env['SELENIUM_MARIONETTE']);
364+
let useMarionette = !noMarionette;
365+
366+
if (useMarionette) {
344367
let service = createGeckoDriverService(binary);
345368
serverUrl = service.start();
346369
onQuit = () => service.kill();

javascript/node/selenium-webdriver/lib/test/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ var build = require('./build'),
2828
fileserver = require('./fileserver');
2929

3030

31+
const LEGACY_FIREFOX = 'legacy-' + webdriver.Browser.FIREFOX;
32+
33+
3134
/**
3235
* Browsers with native support.
3336
* @type {!Array.<webdriver.Browser>}
@@ -36,6 +39,7 @@ var NATIVE_BROWSERS = [
3639
webdriver.Browser.CHROME,
3740
webdriver.Browser.EDGE,
3841
webdriver.Browser.FIREFOX,
42+
LEGACY_FIREFOX,
3943
webdriver.Browser.IE,
4044
webdriver.Browser.OPERA,
4145
webdriver.Browser.PHANTOM_JS,
@@ -46,10 +50,10 @@ var NATIVE_BROWSERS = [
4650
var serverJar = process.env['SELENIUM_SERVER_JAR'];
4751
var remoteUrl = process.env['SELENIUM_REMOTE_URL'];
4852
var useLoopback = process.env['SELENIUM_USE_LOOP_BACK'] == '1';
53+
var noMarionette = /^0|false$/i.test(process.env['SELENIUM_GECKODRIVER']);
4954
var startServer = !!serverJar && !remoteUrl;
5055
var nativeRun = !serverJar && !remoteUrl;
5156

52-
5357
var browsersToTest = (function() {
5458
var permitRemoteBrowsers = !!remoteUrl || !!serverJar;
5559
var permitUnknownBrowsers = !nativeRun;
@@ -63,14 +67,22 @@ var browsersToTest = (function() {
6367
if (parts[0] === 'edge') {
6468
parts[0] = webdriver.Browser.EDGE;
6569
}
70+
if (noMarionette && parts[0] === webdriver.Browser.FIREFOX) {
71+
parts[0] = LEGACY_FIREFOX;
72+
}
6673
return parts.join(':');
6774
});
75+
6876
browsers.forEach(function(browser) {
6977
var parts = browser.split(/:/, 3);
7078
if (parts[0] === 'ie') {
7179
parts[0] = webdriver.Browser.IE;
7280
}
7381

82+
if (parts[0] === LEGACY_FIREFOX) {
83+
return;
84+
}
85+
7486
if (NATIVE_BROWSERS.indexOf(parts[0]) == -1 && !permitRemoteBrowsers) {
7587
throw Error('Browser ' + parts[0] + ' requires a WebDriver server and ' +
7688
'neither the SELENIUM_REMOTE_URL nor the SELENIUM_SERVER_JAR ' +
@@ -145,6 +157,11 @@ function TestEnvironment(browserName, server) {
145157

146158
builder.build = function() {
147159
var parts = browserName.split(/:/, 3);
160+
161+
if (parts[0] === LEGACY_FIREFOX) {
162+
parts[0] = webdriver.Browser.FIREFOX;
163+
}
164+
148165
builder.forBrowser(parts[0], parts[1], parts[2]);
149166
if (server) {
150167
builder.usingServer(server.address());
@@ -199,7 +216,7 @@ function suite(fn, opt_options) {
199216
testing.describe('[' + browser + ']', function() {
200217

201218
if (isDevMode && nativeRun) {
202-
if (browser === webdriver.Browser.FIREFOX) {
219+
if (browser === LEGACY_FIREFOX) {
203220
testing.before(function() {
204221
return build.of('//javascript/firefox-driver:webdriver')
205222
.onlyOnce().go();

javascript/node/selenium-webdriver/test/fingerprint_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ test.suite(function(env) {
5353
});
5454
});
5555

56-
// Currently only implemented in firefox.
57-
}, {browsers: ['firefox']});
56+
// Currently only implemented in legacy firefox.
57+
}, {browsers: ['legacy-firefox']});

0 commit comments

Comments
 (0)