2

Followed this post - https://stackoverflow.com/questions/1414934/selenium-could-not-start-selenium-session-failed-to-start-new-browser-session

Error comes up at selenium.start(). I am using Selenium RC (2.16), junit(4.5) in Eclipse IDE.

The only way to overcome this issue is to redeploy our framework in Tomcat server, just restart everything.

This is the piece of code that starts Selenium:

private static HttpCommandProcessor proc;
    public static DefaultSelenium selenium;

    if (selenium == null) {

        proc = new HttpCommandProcessor("localhost", 4444, browserName,
                urlName);
        selenium = new DefaultSelenium(proc);
        **selenium.start();**
        selenium.setTimeout(String.valueOf(PAGE_TIMEOUT_TIME));
        selenium.useXpathLibrary("javascript-xpath");
        selenium.deleteAllVisibleCookies();             
    }

The Selenium Server is already started when the execution reaches the above code.

Below is the exception that comes up when execute the tests:

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser
      at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:107)
      at <package>.SuperClass.connectToUrl(SuperClass.java:340)

Any help or clue to resolve this thing would be appreciated!

3
  • 1
    Did you run netstat -an | find "4444" to see if selenium server was already running? It sounds like if that's the case you would have to kill the selenium server process and to avoid this in the future, you would want to make sure you are always calling selenium.stop() in your cleanup.
    – Sam Woods
    Jul 17, 2012 at 20:42
  • I have not done a netstat but do call the url -localhost:4444/selenium-server/driver/… from the browser, to see incase the server is up, will shut it down. And yes, selenium.stop() is always called in the after class method. Jul 18, 2012 at 4:46
  • 1
    Can you provide entire stack trace? It might contain another useful message in the middle line. Jan 11, 2013 at 2:13

1 Answer 1

2

It is possible you are running an incompatible version of Firefox with your Selenium version. As mentioned in another question you asked, Selenium RC 2.16 is only compatible up to Firefox 11. After that, you need webdriver. Here is a link to that question:

Firefox browser launches blank page while running tests via Selenium

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.