我正在一些硒测试。 当我从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 ESR 10.0.10。 我也与硒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运行测试,而不答的问题。 他们只是occure,如果我叫“MVN安装”为例
Answer 1:
当我遇到这个错误通常是两件事情之一。
硒版本不支持的浏览器版本 ,仔细检查硒/浏览器版本是相同的在Eclipse的Maven VS跑时。 仔细检查Eclipse和Maven的配置为使用相同的硒版本。 发生这种情况对我来说,当我的浏览器会自动更新,所以我把那个关在浏览器中。
硒测试在无头的模式下运行的可能性不大,如果你在同一台机器上的Eclipse手动执行MVN。 基于Maven我詹金斯服务器上运行硒发生这种情况时我。 詹金斯服务器在无头的模式下运行。 我花了分钟找出无头的东西,我想在Linux或东西设置DISPLAY环境变量。
Answer 2:
我想问题出在哪里了。
我装了一些扩展,添加到我用实例化FireFoxDriver的FirefoxProfile。 这些插件在那里下的Java /主/资源所在。 在Eclipse中一切正常,但我无法通过的Maven访问这些插件。 这些文件复制到一个临时文件夹,并从那里加载它们后,它甚至从Maven的工作。
谢谢你的帮助
Answer 3:
尝试添加以下内容到POM
更新:
<dependency>
<groupId>org.seleniumhq.webdriver</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.XX.X</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.XX.X</version>
</dependency>
Answer 4:
我们有一个类似的问题,经过Linux更新出现。 我们测试了大量的硒版本(2.42.2和2.43.1)和Firefox(27.0.1至32.0.2)的组合,但问题是始终存在。
我们正在OpenMandriva,项目就是Eclipse和Maven下。
我们为我们找到了一个解决方案,那就是更换以下Maven的依赖
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.1</version>
</dependency>
所有下述的:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
我不知道这种解决方案只是隐藏真正的问题?
Answer 5:
如果你已经在试图解决这一问题,更新Firefox和硒到最新版本,并且您仍然面临的问题,您可以使用“重新启动来更新”更新了Firefox浏览器。
关闭Firefox和确保Firefox的可执行文件不再运行。 然后尝试测试。 现在应该工作。
我猜这是关系时完全Firefox的二进制文件,当您使用“重新启动来更新”更新
Answer 6:
我有这个问题与Firefox 36,也是人们面临着同样的35和44。
对于总之,升级您的Firefox 37或它降级到任何低于33。
Answer 7:
争夺了一会儿,并试图大部分(如果不是全部)在这里列出的选项中,我终于通过删除未使用的JAR摆脱这种错误后- ios-server-0.6.5-jar-with-dependencies.jar
在我构建路径,以及使用的组合FF34
和硒罐子2.48.2
。
只是想后本作中情况下,任何一个运行到这个问题衰弱的另一种选择。
Answer 8:
my recommendation is
===> switch to firefox version 50.0 [latest One] ,
===> download the gecko driver from [.](https://github.com/mozilla/geckodriver/releases) and
===> Selenium version 3.0.1
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
==> On your Code
private WebDriver driver;
System.setProperty("webdriver.gecko.driver", "PATH to GECKO DRIVER");
driver = new FirefoxDriver();
and yes you see the below output in your console :
Dec 17, 2016 6:40:45 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
14819XXXXXXX5 mozprofile::profile INFO Using profile path C:\Users\User\AppData\Local\XXXXX\rust_XXXprofile.OXXXXXXXXXXX7S
148XXXXXXXXX0 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
148XXXXXXXXX1 geckodriver::marionette INFO Connecting to Marionette on localhost:XXXXXXX
148198XXXX077 Marionette INFO Listening on port 53532
Dec 17, 2016 6:40:55 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Child 4104] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line XXXX
Dec 17, 2016 6:41:13 PM org.openqa.selenium.os.UnixProcess destroy
Answer 9:
找不到firefoxbinary路径。 请提前用firefox驱动的设置Firefox的路径。
System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
Answer 10:
同样的问题也occures当是你的Firefox的缓存文件夹位于磁盘上没有左空间。 刚释放的空间,并启动你的脚本!
文章来源: Failed to connect to binary FirefoxBinary with Selenium in Maven