Could not start Selenium session: Failed to start new browser session: Error while launching browser

柔情痞子 提交于 2019-12-13 17:11:19

问题


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.


回答1:


Firefox only allows one instance of each profile. If you did not conigure anything for it and your firefox browser is open when starting the test. Firefox blocks selenium from using it.

Configure a profile in Firefox and you can configure selenium to use a ff profile

when you run Selenium Server, run with the server with command-line option -firefoxProfileTemplate "path to the profile"

(in case you didn't configured that)

Configuring profiles in FF




回答2:


I keep having the same issue and have fixed it each time by updating my version of Selenium server to the latest version. It seems that every time Firefox releases a new update it stops old versions of Selenium server from working!



来源:https://stackoverflow.com/questions/3289227/could-not-start-selenium-session-failed-to-start-new-browser-session-error-whi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!