ChromeWebDriver - unknown error: Chrome failed to

2020-01-26 10:06发布

I'm trying to test my application on Chrome with ChromeWebDriver but every time I try I get following exception:

   org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.46 seconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'PADAMSKI-W', ip: '10.10.8.60', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_37'
Driver info: pl.axit.test.selenium.env.KoralinaChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:181)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:149)

In chromedriver.log I see

[0.681][INFO]: Launching chrome: "C:\Users\padamski.AXIT.PL\AppData\Local\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension="C:\Users\PADAMS~1.PL\AppData\Local\Temp\scoped_dir4048_12236\internal" --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12573 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir="C:\Users\PADAMS~1.PL\AppData\Local\Temp\scoped_dir4048_22909" --window-size=6000,6000 data:,
[60.836][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: crashed

I'm using:

  • Chrome 36
  • ChromeWebDriver 2.10
  • Windows 7

In Process Explorer I can see that chromedriver.exe process is running but no window is opened and after few seconds I get above exception.

My starting code is:

 File f = ResourceProvider.getResource("tools/win/chromedriver.exe");
 System.setProperty("webdriver.chrome.driver", f.getAbsolutePath());
 return new ChromeDriver();

8条回答
看我几分像从前
2楼-- · 2020-01-26 11:08
  DesiredCapabilities capability = DesiredCapabilities.chrome();

        System.setProperty("webdriver.chrome.driver", "path to chromedriver.exe");
        capability.setBrowserName("chrome");
        capability.setPlatform(PlatformAndEnvironmentSetUp.platformSetUp);

        driver = new RemoteWebDriver(new URL("http://" + PlatformAndEnvironmentSetUp.hubIP + ":" + PlatformAndEnvironmentSetUp.hubPort + "/wd/hub"), capability);


        this.driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        this.driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        this.driver.manage().window().setSize(new Dimension(1920, 1080));
//page instances init()

        loginPage = PageFactory.initElements(this.driver, LoginPage.class);
        homePage = PageFactory.initElements(this.driver, AdminHomePage.class);

This sample code works OK for me. Just a little note: "chromedriver.exe" I'm placing in the same project folder. That makes the question of path to chromdriver executable easier.

So this line of code looks in this way:

System.setProperty("webdriver.chrome.driver", "chromedriver.exe");

Resource to download chromedriver.exe

Hope this helps you.

查看更多
姐就是有狂的资本
3楼-- · 2020-01-26 11:10

I was able to resolve this issue on Windows 10 by using the Administrator CMD to run my scripts.

查看更多
登录 后发表回答