2016-10-28 39 views
0

下面是使用的代碼:http.con.httphostconnection例外selenium3和Firefox 49使用gecock驅動

System.setProperty("webdriver.gecko.driver", "C:/drivers/geckodriver-v0.9.0-win64/geckodriver.exe"); 
     WebDriver driver = new FirefoxDriver(); 

driver.get(url) 

獲取異常的下方。

org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:42396 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect 
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:16 -0700' 
System info: host: 'sdards', ip: '192.168.1.5', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_101' 
Driver info: driver.version: FirefoxDriver 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127) 
    at com.login.CopyOfToolsnew.setupenv(CopyOfToolsnew.java:53) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
+0

按照此http://stackoverflow.com/questions/39910892/my-code-is-not-working-why/39910945#39910945 –

回答

0

試試:

使用Firefox 49.0.2

使用壁虎司機: https://github.com/mozilla/geckodriver/releases/tag/v0.11.1

(選擇合適的32位或64位版本)

您應該添加這些依賴:

<selenium.version>3.0.1</selenium.version> 


<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-java</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-server</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-firefox-driver</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-api</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-support</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-chrome-driver</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-ie-driver</artifactId> 
    <version>${selenium.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-htmlunit-driver</artifactId> 
    <version>2.52.0</version> 
</dependency> 
<dependency> 
    <groupId>org.seleniumhq.selenium.client-drivers</groupId> 
    <artifactId>selenium-java-client-driver</artifactId> 
    <version>1.0.2</version> 
</dependency> 

System.setProperty("webdriver.gecko.driver", browserWebDriverFilePath); 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
D8 = new FirefoxDriver(capabilities); 
D8.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
D8.manage().window().maximize(); 
+0

感謝的help..i我能夠推出firefox ..但卡住了另一個問題 – surya135

相關問題