线程“main”中的异常org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:正常退出

时间:2018-02-05 15:19:23

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

我正在尝试使用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

2 个答案:

答案 0 :(得分:0)

您的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);

答案 1 :(得分:0)

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