selenium運行測試腳本失敗,提示Unable to connect to host 127.0.0.1

運行環境

瀏覽器版本: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後,程序正常運行。







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章