【问题标题】:Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:Chrome 无法启动:正常退出
【发布时间】:2018-02-05 15:19:23
【问题描述】:

我正在尝试使用 Java 和 Selenium 自动执行常规过程。我尝试使用 Chrome 作为我的浏览器。但我收到错误消息,无法加载浏览器。

以下是错误:

Starting ChromeDriver (v2.3) on port 52793 Exception in thread "main"
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally (Driver info:  chromedriver=2.3,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 22.50 seconds Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'

使用的 Chrome 版本:版本 63.0.3239.132(官方构建)(64 位)

使用的代码:

public static void main(String[] args) throws Throwable {   
System.setProperty("webdriver.chrome.driver", "D:\\Automation\\Thomas_Auto\\Driver\\chromedriver.exe");

ChromeDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://vrijuit.nl/nl/vakanties");
driver.findElement(By.cssSelector("i.basic-sprite.date")).click();
driver.findElement(By.xpath("(//a[contains(text(),'1')])[56]")).click();
driver.findElement(By.cssSelector("a.ui-state-default.ui-state-active.ui-state-hover")).click();
driver.findElement(By.linkText("info & prijs")).click();
driver.findElement(By.cssSelector("input.btn.btn-select")).click();
driver.findElement(By.cssSelector("button.btn-call-to-action")).click();

enter image description here

【问题讨论】:

  • chrome 浏览器加载时出现的错误:禁用开发者模式扩展运行 inn 开发者模式的扩展可能会损害您的计算机。如果您不是开发人员,则应禁用在开发人员模式下运行的这些扩展程序以确保安全。

标签: java google-chrome selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

将您的 ChromeDriver 和 chrome 更新到最新版本,然后重试。

我在我的环境中使用 ChromeDriver 版本 2.35 和 chrome 版本 64.0.3282.140(官方构建)(64 位)运行您的代码,没有问题。

您可以通过 chromeoptions 禁用扩展。

    ChromeOptions options = new ChromeOptions();
    options.addArguments("chrome.switches","--disable-extensions");
    ChromeDriver driver=new ChromeDriver(options);

【讨论】:

  • 感谢思进的帮助,已经可以了。。这个问题是不是版本改了?
  • 这可能是由于启用了开发者模式的 chrome 上的某些扩展造成的。当您在浏览器中安装非 Chrome Web Store 扩展时,Chrome 中会显示警告“禁用开发者模式扩展”。它显示警告是因为 chrome 认为某些恶意软件将扩展强制安装到 Chrome
  • 谢谢思进。这对我很有帮助。
【解决方案2】:

您的 ChromeDriver 似乎不支持driver.manage().window().maximize();

尝试使用 ChromeOptions 来实现相同的效果...例如

System.setProperty("webdriver.chrome.driver","D://Automation/Thomas_Auto/Driver/chromedriver.exe");
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("disable-infobars");
        chromeOptions.addArguments("start-maximized");
        driver = new ChromeDriver(chromeOptions);

【讨论】:

  • 嗨 Gaurav,谢谢,但它没有用。请注意,我在加载 chrome 浏览器时遇到错误。下面是错误。 '“禁用开发者模式扩展程序运行 inn 开发者模式的扩展程序可能会损害您的计算机。如果您不是开发者,则应禁用在开发者模式下运行的这些扩展程序以确保安全”' 你能帮忙吗? .是否需要禁用开发人员选项。如果是,请告诉我该怎么做。
  • 请参考附图。
猜你喜欢
  • 2015-08-14
  • 2014-04-20
  • 2016-10-08
  • 2017-09-07
  • 1970-01-01
  • 2017-10-27
  • 2021-04-19
  • 2017-10-30
  • 1970-01-01
相关资源
最近更新 更多