java 无法启动 Selenium 会话:无法启动新的浏览器会话:启动浏览器时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3289227/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 01:10:03  来源:igfitidea点击:

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

javabrowserseleniumselenium-rc

提问by noktasizvirgul

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.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.

不管怎么说,还是要谢谢你。

回答by Redlab

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.

Firefox 只允许每个配置文件的一个实例。如果您没有为它配置任何东西并且在开始测试时您的 Firefox 浏览器是打开的。Firefox 阻止 selenium 使用它。

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

在 Firefox 中配置配置文件,您可以配置 selenium 以使用 ff 配置文件

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

当您运行 Selenium Server 时,使用命令行选项 -firefoxProfileTemplate“配置文件的路径”与服务器一起运行

(in case you didn't configured that)

(如果你没有配置)

Configuring profiles in FF

在 FF 中配置配置文件

回答by user unknown

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!

我一直遇到同样的问题,每次都通过将我的 Selenium 服务器版本更新到最新版本来修复它。似乎每次 Firefox 发布新更新时,它都会阻止旧版本的 Selenium 服务器工作!