How to stop the selenium server in batch file

697 views
Skip to first unread message

arjun

unread,
Mar 3, 2009, 6:30:43 AM3/3/09
to selenium-users...@googlegroups.com
Basically i am trying to open the selenium server before application gets open like

in setup method i am giving the line
as

Runtime.getRuntime().exec("cmd /c start server.bat");

Command prompt gets open and executes the srver.bat file where in server gets started

now when my test gets complete i need to close that command prompt .ie stop the selenium server so that i run new test

But i am not able to close that command prompt window i used Process class and other method whatever is possible but still i am not able close it

PLS let me the solution for this

Shane

unread,
Mar 3, 2009, 12:18:36 PM3/3/09
to selenium-users...@googlegroups.com
Hi,

Since Selenium uses Jetty server, you should be able to start and stop the server in-process rather than invking the command line.  I am not sure how exactly to do that, you probably need to look up the source if no one has ansewered.

A less ideal option is to shutdown the server by doing an HTTP GET at URL: http://localhost:4444/selenium-server/driver/?cmd=shutDown

You might need to change the port number to match your selenium server

Shane

Shane

unread,
Mar 4, 2009, 12:18:34 AM3/4/09
to selenium-users...@googlegroups.com
{emoticon:__jive_emoticon_name=cool} That is how we do it in ruby: http://selenium.rubyforge.org/rdoc/classes/Selenium/SeleniumServer.html

arjun

unread,
Mar 4, 2009, 5:55:26 AM3/4/09
to selenium-users...@googlegroups.com
When i use this command

Runtime.getRuntime().exec("cmd /c start java -jar selenium-server.jar -interactive -multiwindow"); selenium server will start .i.e command prompt window gets displayed but i want to close that command prompt window so that next if i run the different test case it should new selenium server closing the old one

arjun

unread,
Mar 4, 2009, 5:56:44 AM3/4/09
to selenium-users...@googlegroups.com
directly if i use selenium.shutDownSeleniumServer(); it gives me a null exception

Shane

unread,
Mar 4, 2009, 12:23:11 PM3/4/09
to selenium-users...@googlegroups.com
That is why when you are in Java world, I would recommend start the server directly instead of calling the Java file.  I believe that the NPE you mentioned when calling the shutdown server is because you didn't start the server in process.

arjun

unread,
Mar 5, 2009, 12:08:07 AM3/5/09
to selenium-users...@googlegroups.com
{font:style=font-size: 10pt; color: #0000c0;}if Directly use this line of code will the server will close or i need to add  some extra code

{font:font-size=2|color=#0000c0}selenium
{font}{font}{font:style=font-size: 10pt;}{font:style=color: #000000;}.shutDownSeleniumServer();{font}{font}

{font:style=font-size: 10pt;}{font:style=color: #000000;}As i never used this before as i was opening selenium server manaually ,Now i wanted to do that task automatically start server and shutdown the server and also command window should be visible to the user.{font}{font}



Shane

unread,
Mar 5, 2009, 12:17:30 AM3/5/09
to selenium-users...@googlegroups.com
If you want to show command line window rather than make the log show up in the test, then Runtime.getRuntime().exec(...) is the way to do.  As I mentioned in earlier reply, when you do that, the only way to shutdown the server is through an HTTP GET on that URL

Reply all
Reply to author
Forward
0 new messages