您的位置:首页 > 其它

selenium运行测试脚本失败,提示Unable to connect to host 127.0.0.1

2017-01-02 17:45 477 查看
运行环境

浏览器版本: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后,程序正常运行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐