theintern / leadfoot

A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.
Other
170 stars 25 forks source link

Connection refused when trying to start firefox session - SeleniumTunnel - Environment ordering #97

Closed OliverCulleyDeLange closed 7 years ago

OliverCulleyDeLange commented 7 years ago

Somehow the ordering of the 'environments' config objects affects the creation of the firefox session.

To reproduce:

With the below files in place, run ./node_modules/.bin/intern-runner config=functionaltests/intern-web. Tests should fail with

Suite firefox on any platform FAILED
UnknownError: [POST http://localhost:4444/wd/hub/session / {"desiredCapabilities":{"name":"functionaltests/intern-web","idle-timeout":60,"browserName":"firefox","marionette":true}}] Connection refused
at Server.createSession  <node_modules/leadfoot/Server.js:330:15>
at <node_modules/intern/lib/executors/Runner.js:200:23>
at retry  <node_modules/intern/lib/util.js:804:13>
at <node_modules/dojo/Promise.ts:393:15>
at runCallbacks  <node_modules/dojo/Promise.ts:11:11>
at <node_modules/dojo/Promise.ts:317:4>
at run  <node_modules/dojo/Promise.ts:237:7>
at <node_modules/dojo/nextTick.ts:44:3>
at _combinedTickCallback  <internal/process/next_tick.js:67:7>
at process._tickCallback  <internal/process/next_tick.js:98:9>

TOTAL: tested 1 platforms, 0/1 tests failed; fatal error occurred
Error: Run failed due to one or more suite errors
at emitLocalCoverage  <node_modules/intern/lib/executors/Executor.js:353:18>
at finishSuite  <node_modules/intern/lib/executors/Executor.js:370:15>
at <node_modules/intern/lib/executors/Executor.js:378:8>
at <node_modules/intern/browser_modules/dojo/Promise.ts:393:15>
at runCallbacks  <node_modules/intern/browser_modules/dojo/Promise.ts:11:11>
at <node_modules/intern/browser_modules/dojo/Promise.ts:317:4>
at run  <node_modules/intern/browser_modules/dojo/Promise.ts:237:7>
at <node_modules/intern/browser_modules/dojo/nextTick.ts:44:3>
at _combinedTickCallback  <internal/process/next_tick.js:67:7>
at process._tickCallback  <internal/process/next_tick.js:98:9>

Then reverse the order of the environment objects in the config (see below file) and run again. Tests should pass.

functionaltests/intern-web.js

【 code javascript 】 define({ capabilities: { fixSessionCapabilities: false }, environments: [ // Doesn't work { browserName: 'chrome' }, { browserName: 'firefox', marionette: true }

// Works //        { browserName: 'firefox', marionette: true }, //        { browserName: 'chrome' } ], tunnel: 'SeleniumTunnel', tunnelOptions: { drivers: [ 'chrome', 'firefox' ] }, proxyOnly: false, functionalSuites: [ 'functionaltests/functional' ], excludeInstrumentation: true, maxConcurrency: 1 }); 【 end code 】

functionaltests/functional.js

【 code  】 define(function (require) { var bdd = require('intern!bdd'); var expect = require('intern/chai!expect');

bdd.describe('home screen', function () {

bdd.it('should search for a postcode', function () { return this.remote .get(require.toUrl('src/index.html')) .findAllByCssSelector('#thing') .getVisibleText() .then(function (text) { expect(text).to.contain("hello") }) }); }); }); 【 end code 】

src/index.html

【 code  】 <!DOCTYPE html>

hello

【 end code 】

devDependencies:

【 code  】 "devDependencies": { "chai": "^3.5.0", "chromedriver": "^2.25.1", "intern": "^3.3.2", "selenium-webdriver": "^3.0.0-beta-3" } 【 end code 】

jason0x43 commented 7 years ago

Interesting... Offhand I'm not sure why the order of environments (and correspondingly session creation) would matter, but stranger things have happened.

jason0x43 commented 7 years ago

Do you still have issues if you don't include chromedriver and selenium-webdriver as dependencies?

OliverCulleyDeLange commented 7 years ago

Yeah same problem - It is an interesting one!

jason0x43 commented 7 years ago

Indeed.

Ok, I was finally able to reproduce a similar issue. The key setting seems to be maxConcurrency. With that set to 1, and when chrome is before firefox, I consistently get a hang (not an error, but maybe I just haven't waited long enough) just after Intern finishes the chrome session. With firefox before chrome, both sessions finish. When maxConcurrency is 2, both sessions always finish (at least in all my test runs).

jason0x43 commented 7 years ago

This appears to be an incompatibility between Selenium 2.53.1 (which Dig Dug 1.5 uses) and geckodriver. Dig Dug 1.6 uses Selenium 3.0.1 and doesn't display this problem.

OliverCulleyDeLange commented 7 years ago

For me the error was immediate - no hanging. Yes sorry i forgot to mention that I had only just added the maxConcurrency flag, because I was seeing issues running tests in parallel (tests would pass on firefox and chrome when run individually but not when together concurrently).

How would I test using DigDug 1.6? I tried installing "digdug": "^1.6.1" and running but seeing the same issue. npm list shows digdug 1.5 as a dependency of Intern 3.3.2.

Sorry I'm not familiar with the Javascript package management world - I'm a Java guy really who's somehow been sucked into the front end world temporarily.

jason0x43 commented 7 years ago

Using Intern 3.4.2 should resolve this as it uses Dig Dug 1.6+.

For future reference, to force an updated dependency for testing purposes, after installing a new package version (e.g., digdug 1.6.1), you'll have to remove the package from the node_modules directories of packages that depend on it. For example, when you install digdug 1.6.1 in a project with intern 3.3.2, npm will put digdug 1.6.1 in the project's node_modules directory, then give intern its own copy of digdug 1.5.x in node_modules/intern/node_modules/digdug.

jason0x43 commented 7 years ago

Just checking up -- is this resolved now?

OliverCulleyDeLange commented 7 years ago

Yes, upgrading to Intern 3.4.2 fixed the issue - Sorry I should've said!

jason0x43 commented 7 years ago

No problem, glad to hear things are working!