第一次用selenium webdriver,当根据教程完成selenium+eclipse等的安装配置后,写了简单的脚本运行的时候出现org.openqa.selenium.firefox.NotConnectedException:Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:的错误,
网上查找资料发现是selenium版本与火狐浏览器的版本有对应关系,查看selenium某一版本对应的火狐浏览器的版本可以在selenium下载页面 http://www.seleniumhq.org/download/ (需FQ) 各个版本的changelog中,会记录支持的firefox版本,查看即可
但是selenium的官网经常打不开,我们可以通过下载的jar包查看,(以selenium-server-standalone-2.50.1.jar为例)使用WINRAR打开selenium-server-standalone-2.50.1.jar>org>openqa>selenium>firefox>webdriver.xpi>右键点击install.rdf文件,选择查看文件,打开的为XML文件,在Firefox的注释下可查看对Firefox版本的要求,该文件的内容如下(版本要求已用加粗下划线标注):
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>fxdriver@googlecode.com</em:id>
<em:version>2.50.1</em:version>
<em:type>2</em:type>
<em:name>Firefox WebDriver</em:name>
<em:description>WebDriver implementation for Firefox</em:description>
<em:creator>Simon Stewart</em:creator>
<em:unpack>true</em:unpack>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.0</em:minVersion>
<em:maxVersion>45.0</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetPlatform>Darwin</em:targetPlatform>
<em:targetPlatform>SunOS</em:targetPlatform>
<em:targetPlatform>FreeBSD</em:targetPlatform>
<em:targetPlatform>OpenBSD</em:targetPlatform>
<em:targetPlatform>WINNT_x86-msvc</em:targetPlatform>
<em:targetPlatform>Linux</em:targetPlatform>
<!-- We're probably missing lots of platforms here -->
</Description>
</RDF>
可以看出该2.50.1版本最小需要火狐浏览器3.0,最高需要45.0,根据要求下载合适的浏览器即可。
一下是chrome浏览器与Firefox以及selenium各个版本的下载地址,希望小伙伴们能少走一些弯路!
chrome:
http://google-chrome.en.uptodown.com/mac/old
Firefox:
http://ftp.mozilla.org/pub/firefox/releases/
selenium:
http://selenium-release.storage.googleapis.com/index.html