简体   繁体   English

chrome浏览器和硒异常

[英]chrome browser and selenium exception

I am receiving the following exception for my java code. 我的Java代码收到以下异常。 All I want to do is open up a chrome browser. 我要做的就是打开Chrome浏览器。 I have downloaded the proper chrome driver and stuck it in my google chrome folder under program files x86. 我已经下载了正确的Chrome驱动程序,并将其粘贴在程序文件x86下的google chrome文件夹中。 Right now what happens is, the browser opens and then immediately says that the program has stopped working and then It throws the exception once I click exit on the window. 现在发生的是,浏览器打开,然后立即说该程序已停止工作,然后在我单击窗口上的退出后引发异常。

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)

here is my code so far 到目前为止,这是我的代码

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();

    }

}

Do you know what version of Chrome you are using? 您知道您使用的是哪个版本的Chrome吗? Chances are the latest since Google likes to autoupdate. 自Google喜欢自动更新以来,最新机会就是最新的机会。 You should be using the latest version of Chromedriver. 您应该使用最新版本的Chromedriver。 The traceback you posted says you are using version 2.20 ( Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239 ). 您发布的追溯信息表明您正在使用版本2.20( Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239 )。 The latest is 2.25 which Supports Chrome v53-55 最新的是2.25,支持Chrome v53-55

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM