您的位置:首页 > 运维架构

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055

2016-03-04 15:08 489 查看
Selenium 和 Firefox 版本不兼容的问题解决

在网上找了很久,虽然都说是版本问题,建议降低 Firefox 的版本,或者是升级 Selenium的版本,照着他们的匹配方案,都没有解决我的问题,自己在mvnrepository 上搜索了最新的 selenium-Java

Firefox 版本:39.0.3 ,感谢自己没更新,不知道最新的 43 能不能兼容 selenium的52版。用过的小伙伴麻烦告知一声



selenium-Java 版本:2.52.0

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.52.0</version>
</dependency>


mvnrepository 的链接地址为: mvnrepository

截个图,看看版本信息



下面是代码,验证我说版本是不是成功匹配

package selenium;

import java.io.IOException;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirefoxTest {
public static void main(String[] args) throws IOException {
// 设置 Firefox 的路径
System.setProperty("webdriver.firefox.bin",
"D:\\rj\\work\\firefox\\firefox.exe");

// 创建一个 FirefoxDriver 的接口,用于连接 Firefox
// 创建一个 Firefox 的浏览器实例
WebDriver driver = new FirefoxDriver();

// 让浏览器访问 Baidu
driver.get("http://www.baidu.com");
// 用下面代码也可以实现
// driver.navigate().to("http://www.baidu.com");

// 获取 网页的 title
System.out.println("1 Page title is: " + driver.getTitle());

// 关闭浏览器
driver.quit();

}
}


没设置 pause 时间,手快地截了张图



好了~~~~看到最后的都是 真爱—-〉代码。

selenium 2.52.0 ==〉Firefox 39.0.3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: