8

I am using npm package webdriver-manager to start driver on machine. It fails if the driver is already started.

Is there a way that I can stop and restart the webdriver? Or something like ignore if already started?

cnishina
  • 5,016
  • 1
  • 23
  • 40
Ronak Agrawal
  • 1,006
  • 1
  • 19
  • 48

4 Answers4

5

If you're using Protractor, you can add seleniumServerJar to your config file, and protractor will start/stop the selenium server for you.

exports.config = {
seleniumServerJar: "path/to/selenium-server-standalone-2.45.0.jar",
...
Brine
  • 3,733
  • 1
  • 21
  • 38
  • I was not successful by adding this command. I got following error. C:\Users\xyx\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145 callback(new Error(message)); ^ Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 at ClientRequest. (C:\Users\xyx\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16) at emitOne (events.js:77:13) at ClientRequest.emit (events.js:169:7) at Socket.socketErrorListener (_http_client.js:259:9) at emitOne (events.js:77:13) – Nick Jan 29 '16 at 07:37
3

In bash you can close like this

kill $(ps -ef | grep webdriver | grep -v grep | awk '{ print $2 }')
smirnov
  • 413
  • 3
  • 9
2

Found this in another post

# stop selenium
curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1
Community
  • 1
  • 1
Bruno
  • 31
  • 3
1

This may be helpful ? https://www.npmjs.com/package/grunt-selenium-webdriver thanks.

Manoj
  • 913
  • 1
  • 7
  • 9