【问题标题】:When I run the selenium RC script, I am getting Failed to start new browser, Firefox 3 could not be found in the path!当我运行 selenium RC 脚本时,我无法启动新浏览器,在路径中找不到 Firefox 3!
【发布时间】:2011-03-12 12:29:50
【问题描述】:

当我运行脚本时,我收到以下错误...

我已将 firefox 位置粘贴到系统变量路径中...
我仍然收到以下错误:

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3c:\blah\firefox.exe
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:89)
at com.example.tests.flightbooking.setUp(flightbooking.java:13)
at junit.framework.TestCase.runBare(TestCase.java:128)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:
*firefox3c:\blah\firefox.exe
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)
... 16 more

【问题讨论】:

  • 我在 Windows 7 x64 上遇到了同样的问题,因为 Firefox 安装在 Program Files (x86) 目录中。您可以尝试将 Firefox 文件夹复制到“程序文件”目录(所有内容都保留目录结构)吗?

标签: selenium-rc


【解决方案1】:

使用 firefox 有两种方法可以解决此问题:

  1. 将firefox路径添加到Envirometal变量PATH中如

    E:\Program files\mozilla firefox\firefox.exe

  2. 在测试脚本中添加绝对路径,如:

    selenium = new DefaultSelenium("localhost", 4444, "*firefox E:\\Program files\\mozilla firefox\\firefox.exe", "http://testWebsite.com")

【讨论】:

    【解决方案2】:

    如果您测试 Google Chrome 并在测试中使用 *chrome 作为浏览器,那么此讨论很有用:

    How to run Google Chrome with Selenium RC?

    剧透:*chrome 更改为*googlechrome

    【讨论】:

    • 很好,但这与 Firefox 无关
    • 其实有。如果你使用*chrome Firefox 将被启动。
    【解决方案3】:

    指定 Firefox 可执行目录的绝对路径(浏览器名称和路径之间有空格):*firefox /path/to/dir

    【讨论】:

      【解决方案4】:

      尝试在 DefaultSelenium 中提供 firefox.exe 的绝对路径
      Selenium selenium = new DefaultSelenium("localhost",5555,"*custom /path/to/firefox.exe", "http://url");

      【讨论】:

        【解决方案5】:

        我之前遇到了同样的错误。但是我浏览并找到了更新的 selenium 服务器 jar 文件。

        这样我解决了我的问题。

        【讨论】:

          【解决方案6】:

          我遇到了同样的问题,因为在我正在处理的特定 VM 上,没有空间可以在 C: 驱动器上放置其他任何东西,所以我改用 E:

          我所做的是编辑"System -> Advanced -> Environment Variables" 中的路径以包含:

          E:\Program Files\Mozilla Firefox

          因为这是我安装 Firefox 的地方。我不知道这是否是最好的解决方案,但它让 selenium 起作用。

          【讨论】:

            【解决方案7】:

            我可以通过修改 系统变量:路径

            来解决 Windows 7 中的问题

            1>修改系统变量——路径。

            对于 Windows 7:{假设 firefox.exe 文件位于目录:C:\Program Files (x86)\Mozilla Firefox\firefox.exe}

            • 计算机(右键)-->属性-->高级系统设置-->环境变量-->系统变量-->路径-->双击-->编辑系统变量(弹出)

            • 到变量值末尾加分号;如果它不存在;

            • 添加字符串:*firefox(留一个空格)包含 firefox.exe 文件的目录的路径。不要在路径中添加 firefox.exe。
              *示例:EXISTING_PATH;*firefox C:\Program Files (x86)\Mozilla Firefox*


            解决问题的另一种方法是:(注意:我使用旧的 selenium jar。变量/文件名可能不匹配)

            SeleniumSystemObject 类包含 webBrowser 参数。它要么从环境变量中获取值,要么可以提供绝对路径。

            编辑 SeleniumSystemObject 类中的变量“webBrowser”,以在 webBrowser 参数的值中为 firefox 网络浏览器提供绝对路径: 例如:私有字符串 webBrowser = "*firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

            【讨论】:

              【解决方案8】:

              遇到同样的问题并尝试了上述所有解决方案。系统变量中的 PATH,一个单独的用户变量。问题仍然没有解决,最后归结为 Firefox 不是我的默认浏览器。

              Eclipse 中的选项,Window->Preferences->General->WebBrowser 设置为 - 使用内部 webbrowser 和默认系统 web 浏览器。因此所有的问题。 一旦更改为 Firefox,它就开始工作了。

              浪费了将近 2 个小时试图弄清楚,甚至无法在网上找到这个。所以觉得值得在这里发帖。 :)

              【讨论】:

                【解决方案9】:

                我在尝试使用 selenium-server-standalone-2.44.0.jar 文件运行测试时遇到了同样的错误。我已更改为 selenium-server-standalone-2.39.0.jar 文件,并且我的测试运行良好。

                我正在使用下面的源代码:

                @Before
                public void setUp() throws Exception {
                    selenium = new DefaultSelenium("localhost", 4444, "*chrome", "myURL");
                    selenium.start();
                }
                

                即使在 DefaultSelenium 方法中使用 "*chrome" 作为参数,此代码也会启动我的 firefox。

                【讨论】:

                  【解决方案10】:

                  我建议你使用maven。那样会更容易。 Firefox 带有 selenium 库。你只需要将selenium jar初始化到项目中。然后你就可以使用这个表达式了。

                  Webdriver driver = new FirefoxDriver();
                  

                  在这里你可以找到罐子。

                  http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar

                  【讨论】:

                    【解决方案11】:

                    尝试安装 32 位版本的 Firefox 42.0。这对我来说是个问题;没有找到 64 位版本,但找到了 32 位版本。

                    【讨论】:

                      猜你喜欢
                      • 2016-10-11
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      • 2023-01-07
                      • 2014-08-10
                      • 2020-04-23
                      • 1970-01-01
                      相关资源
                      最近更新 更多