I initialize the selenium like

public void setUp() throws Exception
{
setUp("http://localhost/", "*firefox");
}

and I write my test in the method like

public void testUntitled() throws Exception
{
boo();
foo();
}

But it gives error like

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:89) at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:123) at com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:104) at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:78) at ComserTest_v2.setUp(ComserTest_v2.java:12) at junit.framework.TestCase.runBare(TestCase.java:132) at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212) 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.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) 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) Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: Error while launching browser at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97) at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91) at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262) at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:223) at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:81) ...19 more

I could not find a solution myself and in google results. Any help will be appreciated.

Thanks anyway.

Dani AI

Generated

The stack trace from shows the failure happens inside DefaultSelenium.start(): Selenium RC reports it cannot launch the browser. That message usually means the RC server could not start a browser process (not a network/URL fetch problem). 's suggestion to try a simple reachable page is useful for isolating URL problems, but in most of these cases the real clue is in the Selenium server log. seeing the same symptom is a common report for environment/startup issues rather than test code logic.

Practical checklist (do these in order):

  • Start the Selenium RC server with a log file and inspect the server-side messages. Example:

    java -jar selenium-server.jar -log selenium.log

    The server log shows the low-level error (missing binary, profile lock, display/X issues, permission errors).

  • Verify the browser binary is installed and accessible to the process running the server. If necessary, give RC the full executable path in the browser string. Example launcher form:

    new DefaultSelenium("localhost", 4444, "*firefox /full/path/to/firefox", "http://example/");
  • Check for leftover browser processes and locked profiles (kill stray firefox processes and remove temp profiles created by RC).

  • On headless machines ensure an X server (or Xvfb) is available, or use a headless-capable driver. On Windows, watch for antivirus/UAC blocking process creation.

Common hidden causes: mismatched client/server Selenium versions, tests launched from an IDE with a different environment than a shell, and incorrect browser strings. The server log contains the definitive cause; resolving the message recorded there (missing binary, permission denied, profile error) is the direct path to fixing the "Error while launching browser" failure.

Recommended Answers

All 2 Replies

YOU might get an exception if the url is bad. http://localhost/, not sure where that goes. try http://www.google.com. that's usually what i use for initial testing.

Mike

I had the same problem!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.