2017-06-10 74 views
0

我正在使用Firefox-53,Selenium-3.4並執行下面的代碼,我得到一個錯誤。執行硒時出錯

{ 

    System.setProperty("webdriver.gecko.driver", "D:\\Selenium\\geckodriver.exe"); 
    WebDriver driver ; 
    driver = new FirefoxDriver();driver.get("http://www.store.demoqa.com"); 
} 
enter code here 

錯誤,用法:

enter code here 
D:\Selenium\geckodriver.exe`enter code here` [OPTIONS]`enter code here` 
D:\Selenium\geckodriver.exe: Unknown option --port=26528`enter code here` 
Exception in thread "main"`enter code here` org.openqa.selenium.WebDriverException:`enter code here` org.apache.http.conn.HttpHostConnectException:`enter code here` Connect to localhost:26528 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused 

enter code here 

在此先感謝:-)

+0

接近運行硒獨立,然後再試一次 –

+0

所有的命令提示符在你的代碼結束了刪除文本輸入代碼。 – Murthi

回答

0

似乎是 '請在此輸入代碼' 部分是應該做的。你可以很容易地找到正確的例子,併爲你改變它。

對於examle,

http://toolsqa.com/selenium-webdriver/how-to-use-geckodriver/

package seleniumPrograms; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
public class Gecko_Driver { 

public static void main(String[] args) throws InterruptedException { 
    System.setProperty("webdriver.gecko.driver", "D:\\\\ToolsQA\\trunk\\Library\\drivers\\geckodriver.exe"); 
    WebDriver driver = new FirefoxDriver(); 
    driver.get("http://www.toolsqa.com"); 

    Thread.sleep(5000); 
    driver.quit(); 
} 
}