11

I start Selenium hub to start Selenium Grid from command prompt on port 4444. Now I start Selenium RC from other command prompt.

It shows me error message that "Selenium is already running on port 4444. Or some other service is..."

Now I am not able to start Selenium RC. Please help me how to close /shutdown hub from command prompt.

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
tejas trivedi
  • 111
  • 1
  • 1
  • 3

12 Answers12

14

http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

is the command to close the opened selenium session. If the session is opened using batch file please remove the '@pause' command if its is used. This is useful when we are trying to stop and start the server during or in between test case execution.

Or

"Ctrl + C" is the best option.

Lakshmi V
  • 141
  • 1
  • 2
  • can you please link to the documentation where you found the `shutDownSeleniumServer` cmd ? I’m lost – chitzui Jan 23 '19 at 14:45
8

The URL command shutDownSeleniumServer is no longer supported as of Selenium 3.0.

This github issue suggests that the servlet that manages the lifecycle is still available, but accessible through a different URL:

http://{hubhost}:{hubport}/lifecycle-manager/LifecycleServlet?action=shutdown

If the server is running as a node, the servlet has to be enabled at runtime:

java -jar selenium-server-standalone-3.0.0.jar -role node -servlet org.openqa.grid.web.servlet.LifecycleServlet

And the shutdown URL for a node is:

http://{nodehost}:{nodeport}/extra/LifecycleServlet?action=shutdown

tterry
  • 339
  • 4
  • 8
8

Here is how you can shut it down

http://host-server:port/selenium-server/driver/?cmd=shutDownSeleniumServer

Vaandu
  • 4,857
  • 12
  • 49
  • 75
vmutambuki
  • 81
  • 1
  • 2
3

You only need to hit this link http://localhost:4444/lifecycle-manager?action=shutdown

Anu
  • 556
  • 6
  • 20
2

I am trying this we can also use our web browser to stop the server.

you can try following URL to shut down the server. http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

Humble_PrOgRaMeR
  • 689
  • 4
  • 14
  • 34
1

You'll need to register your RC's with the Selenium Hub. Each RC needs to register on a different port (I think). You can use ant to boot the RC on a specific port

ant -Dport=5556 launch-remote-control

I found running the demos that come with Grid really helpful:

http://selenium-grid.seleniumhq.org/run_the_demo.html

hth

Rodreegez
  • 576
  • 5
  • 15
1

what is safer solution?

kill -p "$SELENIUM_PID"

or

wget http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

i am making a init.d script for headless selenium and this is important step.

pinarella
  • 805
  • 8
  • 16
0

It's easiest to do from a browser (e.g. http://localhost:4444/selenium-server/driver/?cmd=shutDown), but you can also call that url with curl if you need command line access.

Andrew B
  • 839
  • 9
  • 14
0

You can to press "ctrl"+"C" in command window, (where hub or RC is running) and to stop execution of batch file

alexey.chumagin
  • 630
  • 5
  • 16
0

To answer your original question of how do you close selenium hub from the command prompt, you can try this from the selenium-grid folder:
(from documentation)
rake all:restart
rake all:stop

Or for specific ports:
rake all:restart PORTS=5000-5010
rake all:stop PORTS=5000-5010

dhackner
  • 2,942
  • 2
  • 20
  • 23
0

This (http://localhost:4444/lifecycle-manager?action=shutdown) link is removed under version 3.0. In windows, you must stop Java service.

0

If it is running in a command prompt you can use "taskkill" to stop all cmd.exe instances. What I do for selenium grid 4 is start the hub and nodes with specific names via a batch script. And then to stop them I use taskkill to kill the cmd.exe processes with the specified names. I know this isn't the documented way of doing it but it works. Example:

start "SeleniumHub" cmd /c java -jar selenium-server-4.5.0.jar hub

This starts a cmd.exe process with a title of SeleniumHub that we can later reference.

To stop the hub:

taskkill /F /FI "WindowTitle eq  SeleniumHub" /T

where /f is force. /fi is filter based on the window title that equals Seleniumhub and /t is to kill all child processes hope this helps someone.