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

在运行selenium2.53.1版本的测试脚本时,使用firefox50.1.0遇到了org.openqa.selenium.firefox.NotConnectedException错误,提示无法连接到127.0.0.1:7055。问题的根本原因是浏览器版本与selenium版本不兼容。升级selenium到3.0.1后,问题得到解决,脚本能够正常运行访问百度首页。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

运行环境

浏览器版本: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后,程序正常运行。







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值