how to close selenium hub/grid from command prompt
Asked Answered
L

12

12

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.

Loren answered 25/3, 2010 at 10:48 Comment(0)
C
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.

Canonize answered 30/4, 2012 at 10:10 Comment(1)
can you please link to the documentation where you found the shutDownSeleniumServer cmd ? I’m lostFaletti
T
9

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

Tractor answered 6/12, 2016 at 21:10 Comment(0)
L
8

Here is how you can shut it down

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

Lang answered 24/9, 2011 at 19:27 Comment(0)
L
3

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

Lafontaine answered 6/9, 2019 at 10:21 Comment(0)
K
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

Korns answered 3/4, 2015 at 4:1 Comment(0)
B
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

Bentwood answered 28/3, 2010 at 22:49 Comment(0)
H
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.

Halm answered 8/4, 2015 at 9:47 Comment(1)
Did you get a comment regarding which is safer?Bensen
R
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.

Retrogress answered 25/3, 2010 at 10:53 Comment(0)
P
0

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

Phenobarbitone answered 23/8, 2010 at 22:39 Comment(0)
P
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

Pouter answered 18/10, 2010 at 22:26 Comment(0)
C
0

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

Chem answered 31/1, 2020 at 9:25 Comment(1)
@GeorgeZ. It is not a link to a solution.Dall
S
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.

Shope answered 24/1, 2023 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.