运行环境
浏览器版本:firefox50.1.0
selenium:selenium2.53.1
运行脚本
package simpletest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ById {
public static void main(String[] args) {
WebDriver driver = null;
System.setProperty("webdriver.gecko.driver", "/Users/chenxuejiao/TestTools/selenium2.53.1/geckodriver");
driver = new FirefoxDriver();
driver.get("https://www.baidu.com/");
driver.close();
}
}
运行时出现的问题
使用selenium运行访问百度首页时失败,提示org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms
原因分析
网上搜索,造成此问题原因是由于firefox版本和selenium版本不匹配造成的。由于我的firefox版本比较新,所以我猜想,应该是我的selenium jar包过低。
解决方案
下载最新的selenium-server-standalone-3.0.1后,程序正常运行。
在运行selenium2.53.1版本的测试脚本时,使用firefox50.1.0遇到了org.openqa.selenium.firefox.NotConnectedException错误,提示无法连接到127.0.0.1:7055。问题的根本原因是浏览器版本与selenium版本不兼容。升级selenium到3.0.1后,问题得到解决,脚本能够正常运行访问百度首页。
1328

被折叠的 条评论
为什么被折叠?



