【发布时间】:2012-11-10 22:45:32
【问题描述】:
我正在运行一些 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-server 工件依赖于 servlet-api-2.5 工件,如果您的项目将在 Web 应用程序容器中运行 - 来自 Selenium hq.org,您应该排除它。跨度>
-
还有为什么你需要 selenium-api 依赖?
-
我只是尝试了一些东西。现在我添加了排除并删除了 selenium-api 依赖,但问题还是一样
-
您可以尝试设置
webdriver.firefox.logfile系统属性以从Firefox获取日志。 -
问题是,maven 无法启动 firefox,所以没有日志 ;)
标签: java maven selenium junit selenium-webdriver