2016-12-07 5 views
0

私のJavaコードには次の例外があります。私がしたいのはクロームブラウザを開くことだけです。私は適切なクロムドライバをダウンロードして、プログラムファイルx86の下にあるGoogle Chromeのフォルダに貼り付けました。今、何が起こるかは、ブラウザが開き、すぐにプログラムが動作を停止したと表示され、ウィンドウ上でexitをクリックすると例外がスローされます。ここクロムブラウザとセレンの例外

Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239 
Only local connections are allowed. 
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40' 
System info: host: 'W7LPC01TDFU', ip: '10.95.7.58', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79' 
Driver info: driver.version: ChromeDriver 
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665) 

は私のコードは

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver; 

public class mainTester { 


public static void main(String[] args) throws InterruptedException{ 

    setUp(); 
} 
public static void setUp() throws InterruptedException { 
     // Optional, if not specified, WebDriver will search your path for chromedriver. 
     System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe"); 

     WebDriver driver = new ChromeDriver(); 
     driver.get("http://www.google.com/xhtml"); 
     Thread.sleep(5000); // Let the user actually see something! 
     WebElement searchBox = driver.findElement(By.name("q")); 
     searchBox.sendKeys("ChromeDriver"); 
     searchBox.submit(); 
     Thread.sleep(5000); // Let the user actually see something! 
     System.out.println("Finished"); 
     driver.quit(); 

    } 

} 

答えて

1

あなたが使用しているクロームのバージョンを知っています今のところありますか?チャンスはGoogleが自動更新を好きなので最新です。 Chromedriverの最新バージョンを使用しているはずです。あなたが投稿したトレースバックはあなたがバージョン2.20(Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239)を使用していると言います。最新は2.25ですクロムをサポートしていますv53-55

+0

トリックをしました、ありがとう! –

関連する問題