org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055
阿新 • • 發佈:2019-01-30
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