Connection refused! Selenium server is running

I inherited the project in work without documentation. This is a sails.js application. There is a small set of unit tests and an end-to-end test.

When I try to run an end-to-end test using grunt. I get:

$ grunt e2e Running "nightwatch" task started - PID: 5440 >> Executing "default" tests (standalone) [Index] Test Suite ================== Running: Should clean the collection removing 0 places >> Connection refused! Is selenium server started? 

I do not know what I can lose. It made me linger for a week.

The project has selenium-server-standalone-2.40.0.jar in grunt-nightwatch. Therefore, I take the PID - this is the start of the selenium server. If I first run the jar (outside the grunt), I get

 $ grunt e2e org.openqa.grid.selenium.GridLauncher main INFO: Launching a standalone server 18:38:46.189 WARN - Failed to start: SocketListener0@0.0.0.0 :4444 Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is. at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:491) at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:300) at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245) at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:95) >> Could not start Selenium. 

Here is the nightwatch.json

 { "src_folders" : ["tests/e2e"], "custom_commands_path" : "", "custom_assertions_path" : "", "globals_path" : "", "selenium" : { "start_process" : false, "server_path" : "", "log_path" : "", "host" : "127.0.0.1", "port" : 4444, "cli_args" : { "webdriver.chrome.driver" : "", "webdriver.ie.driver" : "" } }, "test_settings" : { "default" : { "launch_url" : "http://localhost", "selenium_port" : 4444, "selenium_host" : "localhost", "silent": true, "screenshots" : { "enabled" : false, "path" : "" }, "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true, "acceptSslCerts": true } }, "chrome" : { "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true, "acceptSslCerts": true } } } } 

Thank you so much for any help!

ps In window 7 window

+7
source share
5 answers

Thanks so much for including the nightwatch.json file.

I think Jordan points to part of the problem. Because of the box, I could not get Nightwatch to work in Chrome. In my .json file there was Firefox, which, as you say, is Chrome. I had to download Firefox and it worked without actually installing the drivers that Jordan mentioned.

My next problem was the server.

I set the selenium start_process to true; nightwatch automatically starts the server when you run tests using grunt. You also need to set server_path in some/directory/selenium-server-standalone-2.40.0.jar .

Regardless of whether this solves your immediate problem, it is likely to save you time in the future if you do not have to start the server and then run the tests.

+7
source
  "webdriver.chrome.driver" : "", 

You need to indicate the location of your chrome driver in this line of the nightwatch.json file

For example, I use:

 "webdriver.chrome.driver" : "~/bin/chromedriver", 

Also do you start selenium to use the chrome driver? If not, when you download selenium, add: -Dwebdriver.chrome.driver = / Users / [username] / bin / chromedriver

So, when you start the selenium server, it should look like terminal cmd: java -jar [SeleniumServerName] -Dwebdriver.chrome.driver = / Users / [username] / bin / chromedriver

First, remember the CD in the seleniumserver folder and change the path structure of the Windows-based file / folder.

+5
source

just in case someone else will fight too.

I have had this problem the last couple of days. The problem was in my case, the chromedriver version was not compatible with the chrome version. I could not tell from the night vision output, but added a magazine that told me.

I originally saw

 Starting selenium server... started - PID: 12835 ... { Error: Unhandled "error" event. ([object Object]) at ClientManager.emit (events.js:185:19) at Nightwatch.<anonymous> (/home/n23430/dev/Ps.Web/WebTest/ps-web-test/node_modules/nightwatch/lib/runner/clientmanager.js:67:10) at Object.onceWrapper (events.js:316:30) at emitOne (events.js:115:13) at Nightwatch.emit (events.js:210:7) at HttpRequest.<anonymous> (/home/n23430/dev/Ps.Web/WebTest/ps-web-test/node_modules/nightwatch/lib/index.js:501:10) at emitThree (events.js:135:13) at HttpRequest.emit (events.js:216:7) at IncomingMessage.<anonymous> (/home/n23430/dev/Ps.Web/WebTest/ps-web-test/node_modules/nightwatch/lib/http/request.js:168:16) at emitNone (events.js:110:20) at IncomingMessage.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1047:12) at _combinedTickCallback (internal/process/next_tick.js:102:11) at process._tickCallback (internal/process/next_tick.js:161:9) context: { message: 'Connection refused! Is selenium server started?\n', data: { value: [Object], status: 33 } } } 

As I noticed the problem In the above trace, there is a link to line 501 in / node_modules / nightwatch / lib / index.js. I added the console.log statement here, printing here the β€œdata” that reads this (from the beginning):

 { "value": { "stacktrace": "org.openqa.selenium.SessionNotCreatedException: session not created exception: Chrome version must be >= 60.0.3112.0\n (Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.4.0-79-generic x86_64) (WARNING: The server did not provide any stacktrace information)... 

Conclusion The version of chrome version 2.33 needs the version chrome> = 60. Updating chrome resolved my problem.

Regards, Aril

+2
source

My problem arose because in my / etc / hosts file I had 127.0.0.1 not pointed to by localhost. I fixed it and this solved the problem.

0
source

I had the same problem the first time I started the Selena server.

If the selenium console http: // localhost: 4444 / wd / hub / also does not start the session, the web driver is probably not placed or is not in the PATH variable. If you use a Chrome browser, try downloading chromedriver from https://chromedriver.storage.googleapis.com/ or run npm install chromedriver .

If you downloaded the driver executable separately, be sure to add it to your PATH.

0
source

Source: https://habr.com/ru/post/978932/


All Articles