问题描述
我正在尝试使用 ChromeWebDriver 在 Chrome 上测试我的应用程序,但每次尝试时都会出现以下异常:
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)
在 chromedriver.log 中我看到
In chromedriver.log I see
[0.681][INFO]: Launching chrome: "C:Userspadamski.AXIT.PLAppDataLocalGoogleChromeApplicationchrome.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:UsersPADAMS~1.PLAppDataLocalTempscoped_dir4048_12236internal" --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:UsersPADAMS~1.PLAppDataLocalTempscoped_dir4048_22909" --window-size=6000,6000 data:,
[60.836][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: crashed
我正在使用:
- 铬 36
- ChromeWebDriver 2.10
- Windows 7
在进程资源管理器中,我可以看到 chromedriver.exe 进程正在运行,但没有打开任何窗口,几秒钟后我得到了上述异常.
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.
我的起始代码是:
File f = ResourceProvider.getResource("tools/win/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", f.getAbsolutePath());
return new ChromeDriver();
推荐答案
最终我发现 WebDriver 试图从 C:Users\______AppDataLocalGoogleChromeApplicationchrome 运行 Chrome.exe
,即使手动尝试也不起作用.这很奇怪,因为当我启动 Chrome 时,我使用安装在 Program Files
目录中的一个,它可以正常工作.
Eventually I found out that WebDriver was trying to run Chrome from C:Users\______AppDataLocalGoogleChromeApplicationchrome.exe
, which was not working even when trying it manually. It was very strange because when I launch Chrome I use one installed in Program Files
directory and it works without problems.
所以我卸载了 Chrome,从 c:Users______AppDataLocalGoogleChrome
中删除了所有内容,然后再次安装了 Chrome.之后它开始工作.
So I had uninstalled Chrome, deleted everything from c:Users______AppDataLocalGoogleChrome
and installed Chrome again. After that it started working.
这篇关于ChromeWebDriver - 未知错误:Chrome 无法启动:崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!