2014-08-29 126 views
-1

我是新來的網絡驅動程序,並試圖做一些簡單的自動化。我只是想啓動瀏覽器並使用selenium webdriver打開一個網頁。我設置了eclipse-selenium並啓動了Firefox,但沒有打開我指定的網頁。我收到了一些奇怪的錯誤。我瀏覽瞭解決方案並嘗試了很多我發現的建議。無法通過硒webdriver在Firefox中打開網頁

這裏是我試圖執行代碼:

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

public class orderingpizza { 
public static void main(String[] args) { 

    WebDriver driver = new FirefoxDriver(); 
    driver.get("http://www.google.com/"); 

我正的錯誤是:

產生的原因:org.openqa.selenium.firefox.NotConnectedException:無法在45000毫秒後通過端口7055連接到主機127.0.0.1。 Firefox控制檯輸出:

我使用Selenium java 2.42.2,FF 29.這是什麼問題?

+0

嘗試您使用SEL和Firefox火狐升級到31 – 2014-08-29 08:04:46

+0

什麼版本? – Decypher 2014-08-29 08:41:48

+0

當我與WebDriver和Chrome出現類似錯誤時。我不得不重新安裝Chrome,然後開始工作。 – 2014-08-29 10:58:47

回答

0

這是因爲版本問題。嘗試升級Firefox和硒到兼容版本

1

升級Firefox版本和Selenium。同時升級你的geckodriver.exe

在路徑中使用單斜槓「/」或雙反「\」。試試這個代碼是在Firefox版本49.0和硒3.4.0罐子做工精細

System.setProperty("webdriver.gecko.driver", "E:/software and tools/geckodriver.exe"); 
WebDriver driver = new FirefoxDriver(); 
driver.get("https://www.quora.com");