最近使用selenium的时候,遇到一个错误,具体错误如下:
org.openqa.selenium.WebDriverException: The driver server has unexpectedly died!
Build info: xxxxx
Driver info: driver.version: FirefoxDriver
at
xxxxx.....
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:46859 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused
xxxxx.....
Caused by: java.net.ConnectException: Connection refused
xxxxx.....
关键信息如上所示。
说一下环境配置:
(1)jdk 1.8
(2)selenium 3.3.1
(3)firefox 52.0
(4)geckodriver 0.9.0
这个问题出现状况是,在当前的jdk以及selenium版本下,chrome等浏览器都能够正常启动,顺便一说,chromedriver
的版本为2.29。
然后赶紧很奇怪,查询了一下geckodriver的0.15.0版本的下载文档发现这样一句话:
IMPORTANT: If you use geckodriver with Selenium, you must upgrade to Selenium 3.3 since this release aligns HTTP responses with the WebDriver standard.
后来将geckodriver版本升级为0.15.0发现问题解决。
这里说一句,selenium自从3出来以后,都是不向下兼容的。如果出现问题,首先要检查的就是版本。
而且,貌似Firefox>=52.0版本的需要用最新的Selenium和最新的Webdriver(3.3.0+)。