gpt4 book ai didi

java - 无法在 Maven 中使用 Selenium 连接到二进制 FirefoxBinary

转载 作者:IT老高 更新时间:2023-10-28 20:58:35 26 4
gpt4 key购买 nike

我正在运行一些 Selenium 测试。当我直接从 Eclipse 启动它们时,一切正常。但是当我通过 Maven 启动它们时,会出现以下异常:

org.openqa.selenium.WebDriverException(Failed to connect to binary FirefoxBinary(C:\winapp\Firefox\firefox.exe) on port 7055; process output follows: 
null
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35'
Driver info: driver.version: FirefoxDriver)

我使用的是 Firefox 10.0.10 ESR。我也用 Selenium 2.25.0 尝试过。

这是我最新版本的 pom.xml:

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.26.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.26.0</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>

如果我可以为您提供更多信息,请告诉我。

编辑:更新 pom.xml

edit2:最让我惊奇的是,我可以从 Eclipse 运行测试而不会出现 ans 问题。例如,如果我调用“mvn install”,它们就会发生

最佳答案

当我遇到此错误时,通常是以下两种情况之一。

Selenium 版本不支持浏览器版本从 Eclipse 与 Maven 运行时,仔细检查 Selenium/浏览器版本是否相同。仔细检查 Eclipse 和 Maven 配置为使用相同的 Selenium 版本。当我的浏览器自动更新时发生这种情况,所以我在浏览器中关闭了它。

Selenium 测试以 headless 模式运行如果您在与 Eclipse 相同的机器上手动执行 mvn,则不太可能。在我的 Jenkins 服务器上通过 Maven 运行 Selenium 时,这发生在我身上。 Jenkins 服务器以 headless 模式运行。花了我一分钟才弄清楚 headless 的东西,我想我在 Linux 中设置了一个 DISPLAY 环境变量或其他东西。

关于java - 无法在 Maven 中使用 Selenium 连接到二进制 FirefoxBinary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13514338/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com