Technical Project Lead @ Huawei Technologies

My photo
Bangalore/Hyderabad, Karnataka/Andhra Pradesh, India
Have an overall 13 + yrs of experience Currently working as an Senior Architect.Expertise in design,implementation of Automation frameworks for Opensource automation tools like Selenium,Jmeter, Webdriver,Appium, Robotium Expertise in integrating Test & ALM Management tools like Rally,Qmetry,JIRA-Zephyr with Automation frameworks Expertise in design and developmenet Mobile Automation frameworks for tools like Appium, Robotium Remote Control,Cucumber BDD,Manual Testing

Followers

Saturday, September 4, 2010

How to shut down Selenium Server if it is already running on port 4444

There are chances that when you are running tests, the server might not be shutdown properly. In this case, when you try to re-run your tests, you may encounter the following error

java.net.BindException: Selenium is already running on port 4444. Or some other service is.
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:399)
    at login.testLogin(login.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Solution for the above problem is , type the below in the browser URL and the server will be stopped
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
Now your should be able to see the message "OKOK" in the browser window

6 comments:

  1. hey that solved a problem i had in orphaned server instances running. Thank you for your post.

    -devi

    ReplyDelete
  2. Or what you can even do is -
    DefaultSelenium selenium = new DefaultSelenium(....);
    ...
    ..
    teardown()
    {
    selenium.shutDownSeleniumServer();
    selenium.stop();
    seleniumServer.stop();
    }

    ReplyDelete
  3. I am getting this error with the URL provided:

    ERROR: ERROR: No sessionId provided. Most likely your original newBrowserSession command failed.

    ReplyDelete
  4. i am still not able to shut down selenium however i am getting that "OKOK" on browser

    ReplyDelete
  5. Cool, this helped me out. Thanks!

    ReplyDelete