webdriverio-boneyard / wdio-selenium-standalone-service

WebdriverIO v4 service to start & stop Selenium Standalone http://webdriver.io
MIT License
54 stars 28 forks source link

Selenium starts but doesn't work #23

Closed phawxby closed 7 years ago

phawxby commented 7 years ago

Windows 10 x64 Enterprise

After running the test command I can see Selenium has started but it fails to run any tests and throws an unable to connect error. Any help would be much appreciated.

image

Dependencies (truncated)

  "devDependencies": {
    "mocha": "^3.3.0",
    "wdio-mocha-framework": "^0.5.10",
    "wdio-selenium-standalone-service": "0.0.8",
    "webdriverio": "^4.7.1"
  }

Gulpfile

gulp.task('test:wdio', function(cb) 
{
    var wdio = new Launcher(path.join(__dirname, 'wdio.conf.js'));

    return wdio.run(code => {
    process.exit(code);
  }, error => {
    console.error('Launcher failed to start the test', error.stacktrace);
    process.exit(1);
  });
});

Output

PS C:\Users\Z269CJBB\Documents\GitHub\xerox-drupal> gulp test
[14:37:33] Using gulpfile ~\Documents\GitHub\xerox-drupal\gulpfile.js
[14:37:33] Starting 'test:wdio'...

A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
    at Timeout.hasStarted (C:\Users\Z269CJBB\Documents\GitHub\xerox-drupal\node_modules\selenium-standalone\lib\check-started.js:17:10)
    at ontimeout (timers.js:380:14)
    at tryOnTimeout (timers.js:244:5)
    at Timer.listOnTimeout (timers.js:214:5)

Continue...

=======================================================================================
Selenium 2.0 / webdriver protocol bindings implementation with helper commands in nodejs.
For a complete list of commands, visit http://webdriver.io/api.html.
=======================================================================================

[14:38:59]  COMMAND     POST     "/wd/hub/session"
[14:38:59]  DATA                {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"maxInstan
ces":5,"browserName":"chrome","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.6.2","name":"webdriver
io"}}}
ERROR: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>

chrome
Error: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>

[14:38:59] Finished 'test:wdio' after 1.43 min
JUhrig commented 7 years ago

Experiencing a similar issue on Jenkins (CentOS) running with slightly different dependencies. This is from the WillLuce/WebdriverIO_Typescript boiler plate.

Dependencies:

"devDependencies": {
    "@types/chai": "^3.4.34",
    "@types/mocha": "^2.2.32",
    "@types/webdriverio": "^4.4.0",
    "chai": "^3.5.0",
    "rimraf": "^2.5.4",
    "typescript": "^2.0.6",
    "wdio-junit-reporter": "^0.3.0",
    "wdio-mocha-framework": "^0.5.7",
    "wdio-selenium-standalone-service": "0.0.7",
    "webdriverio": "^4.8.0"
  }

Output:

+ npm run test
> webdriver_typescript@1.0.0 test /var/jenkins/workspace/QA/Test-Project/default
> node ./node_modules/typescript/lib/tsc.js && node ./node_modules/webdriverio/bin/wdio && node ./node_modules/rimraf/bin.js src

A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
    at Timeout.hasStarted (/var/jenkins/workspace/QA/Test-Project/default/node_modules/selenium-standalone/lib/check-started.js:17:10)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

ERROR: connect ECONNREFUSED 127.0.0.1:4444
chrome
Error: connect ECONNREFUSED 127.0.0.1:4444
ERROR: connect ECONNREFUSED 127.0.0.1:4444
firefox
Error: connect ECONNREFUSED 127.0.0.1:4444

With the above error I am unsure if the selenium server even started. The configuration does work locally just when attempting to run it on Jenkins does it show this behaviour.

darrenv-speedline commented 7 years ago

We are getting a similar error message under version 0.0.8. Meanwhile 0.0.5 works just fine.

A service failed in the 'onPrepare' hook
Error: Selenium server did not start.
Another Selenium process may already be running or your java version may be out of date.
Be sure to check the official Selenium release notes for minimum required java version: https://raw.githubusercontent.com/SeleniumHQ/selenium/master/java/CHANGELOG

    at ChildProcess.errorIfNeverStarted (/home/travis/build/SpeedlineSolutions/SL-OLO/functional-tests/node_modules/selenium-standalone/lib/start.js:152:10)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

Continue...
ERROR: connect ECONNREFUSED 127.0.0.1:4444
phantomjs
Error: connect ECONNREFUSED 127.0.0.1:4444

ERROR: connect ECONNREFUSED 127.0.0.1:4444
firefox
Error: connect ECONNREFUSED 127.0.0.1:4444
christian-bromann commented 7 years ago

@darrenv-speedline your error is obvious:

Another Selenium process may already be running or your java version may be out of date. Be sure to check the official Selenium release notes for minimum required java version: https://raw.githubusercontent.com/SeleniumHQ/selenium/master/java/CHANGELOG

That seems to be not related to this bug.

christian-bromann commented 7 years ago

Closing due to inactivity.

qtgye commented 7 years ago

Leaving the following links here which solved this problem for me:

Mine was basically a java path issue. Applying the instructions on the stackoverflow link worked for me.

osmolyar commented 6 years ago

Getting the same error, but I don't have a dependency on wdio-selenium-standalone-server in package.json (was not trying to use it and Jasmine suites run fine via the same Jenkins setup without it, though the corresponding Cucumber-framework suite prompted for wdio-selenium-standalone-server to be installed).

It is likely there is already a Selenium process running on port 4444 (which I am using), as http://127.0.0.1:4444/wd/hub/sessions is accessible (but says " "status":13,"value":{"message":"Session [(null externalkey)] not available and is not among the last 1000 terminated sessions.\nActive sessions are[ext. key 6319236f-122c-4001-b651-ad6871249ab0, ext. key 88bbbab0-79e6-43a1-b6ed-98b0780b1562, ext. key 5c70efc4-0b24-4464-9567-e02cd18f5965]","class":"org.openqa.grid.common.exception.GridException","stackTrace"" ). The grid console is also available, and says http://127.0.0.1:4444/grid/console?config=true&configDebug=true: ub launched with : -browserTimeout 120000 -debug false -help false -log log\hub_4444.log -port 4444 ....

Log Error: A service failed in the 'onPrepare' hook Error: Unable to connect to selenium at Timeout.hasStarted [as _onTimeout] (C:\Users\quality\AppData\Roaming\npm\node_modules\wdio-selenium-standalone-service\node_modules\selenium-standalone\lib\check-started.js:17:10) at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5)

The error indicates it is trying to connect to wdio-selenium-standalone-service in this case and not the Hub instance that the Jasmine suite is running. Is there a way to have it not require/try to use wdio-selenium-standalone-service?

Package.json currently has the following dependencies listed: "dependencies": { "Faker": "^0.7.2", "colors": "^1.1.2", "download-file": "^0.1.5", "follow-redirects": "^1.2.1", "lodash": "^4.17.4", "cucumber": "2.3.1", "babel-preset-es2015": "~6.24.0", "babel-register": "~6.26.0", "wdio-cucumber-framework": "^1.1.0", "wdio-allure-reporter": "^0.1.3", "wdio-junit-reporter": "^0.3.1", "wdio-spec-reporter": "0.0.5", "webdriverio": "^4.6.2", "yargs": "^6.6.0" }, "devDependencies": { "wdio-cucumber-framework": "^1.1.0", "wdio-allure-reporter": "^0.1.3", "wdio-junit-reporter": "^0.3.1", "chai": "~4.1.2", "babel-jest": "~22.1.0", "babel-polyfill": "~6.26.0", "eslint": "~4.16.0", "eslint-config-airbnb-base": "~12.1.0", "eslint-plugin-import": "~2.8.0", "forever": "~0.15.3", "http-server": "~0.11.0", "jest": "~22.1.0" }