ChromeWebDriver - 未知错误:Chrome无法启动:崩溃

时间:2023-01-22 18:26:01

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

我正在尝试使用ChromeWebDriver在Chrome上测试我的应用程序,但每次尝试时都会出现以下异常:

   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

在chromedriver.log中我看到了

[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
  • Chrome 36
  • ChromeWebDriver 2.10
  • ChromeWebDriver 2.10
  • Windows 7
  • 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.

在Process Explorer中,我可以看到chromedriver.exe进程正在运行但没有打开窗口,几秒钟后我就遇到异常。

My starting code is:

我的起始代码是:

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

8 个解决方案

#1


6  

Eventually I found out that WebDriver was trying to run Chrome from C:\Users\______\AppData\Local\Google\Chrome\Application\chrome.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.

最后我发现WebDriver试图从C:\ Users \ ______ \ AppData \ Local \ Google \ Chrome \ Application \ chrome.exe运行Chrome,即使手动尝试也无法运行。这很奇怪,因为当我启动Chrome时,我使用安装在Program Files目录中的一个,它没有问题。

So I had uninstalled Chrome, deleted everything from c:\Users______\AppData\Local\Google\Chrome\ and installed Chrome again. After that it started working.

所以我卸载了Chrome,删除了c:\ Users ______ \ AppData \ Local \ Google \ Chrome \中的所有内容,并再次安装了Chrome。之后它开始工作了。

#2


4  

I had the same problem as above. and I solved it. I run selenium with chromium in alpine. My environment:

我遇到了和上面相同的问题。我解决了我在高山中运行含铬的硒。我的环境:

  • Alpine (Linux 3.13.0-24-generic x86_64)
  • Alpine(Linux 3.13.0-24-通用x86_64)
  • Chromium 53.0.2785.92
  • 铬53.0.2785.92
  • chromedriver=2.22
  • chromedriver = 2.22
  • selenium (3.0.1)
  • 硒(3.0.1)

and I met the error information is:

我遇到的错误信息是:

File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error:    Chrome failed to start: crashed
(Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.13.0-24-generic x86_64)

My solution is run:

我的解决方案是运行:

apk add libexif udev

and Then it works.

然后它的工作原理。

I refer to here : https://hub.docker.com/r/rodrigomiguele/chromium/~/dockerfile/

我在这里指的是:https://hub.docker.com/r/rodrigomiguele/chromium/~/dockerfile/

#3


2  

  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.

这个示例代码对我来说很好用。只是一点注意:“chromedriver.exe”我放在同一个项目文件夹中。这使得chromedriver可执行文件的路径更容易。

So this line of code looks in this way:

所以这行代码看起来像这样:

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

Resource to download chromedriver.exe

资源下载chromedriver.exe

Hope this helps you.

希望这对你有所帮助。

#4


2  

Uninstall, delete chrome profile from c:\Users______L\AppData\Local\Google\Chrome\ and reinstall chrome will fix the problem, it worked for me

卸载,从c:\ Users ______ L \ AppData \ Local \ Google \ Chrome \删除chrome配置文件并重新安装chrome将解决问题,它对我有用

#5


1  

I fixed this on Windows 10 by setting chromedriver.exe, [yourPythonIDE].exe, and chrome.exe to run with Administrator rights, which can reached via right-clicking the exe file and going to Properties >> Compatibility.

我通过将chromedriver.exe,[yourPythonIDE] .exe和chrome.exe设置为以管理员权限运行来修复此问题,可以通过右键单击exe文件并转到属性>>兼容性来实现。

#6


0  

I had the same problem as above. Turned out I somehow managed to have two chrome.exe installed. One under Program Files and on under user\appdata\local..... I uninstall the one under Program Files and now it works like a charm.

我遇到了和上面相同的问题。原来我设法安装了两个chrome.exe。一个在Program Files下,在用户\ appdata \ local下...我卸载Program Files下的一个,现在它就像一个魅力。

#7


0  

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

通过使用Administrator CMD运行我的脚本,我能够在Windows 10上解决此问题。

#8


-1  

im pretty sure looking at your error that your bindings for chrome may not be right - please try removing all your references to chrome and removing it from your project. then, if you havent already, install Nuget Packet Manager and download chrome webdriver from there - note there are 2 one by chromium and one from selenium.

我非常肯定会看到你的错误,你的chrome绑定可能不正确 - 请尝试删除所有你对chrome的引用并从项目中删除它。然后,如果你还没有,安装Nuget Packet Manager并从那里下载chrome webdriver - 注意有2个来自铬,1个来自selenium。

hope this helps - let me know and if not ill take a closer look at it.

希望这会有所帮助 - 让我知道,如果不是生病,请仔细看看它。

#1


6  

Eventually I found out that WebDriver was trying to run Chrome from C:\Users\______\AppData\Local\Google\Chrome\Application\chrome.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.

最后我发现WebDriver试图从C:\ Users \ ______ \ AppData \ Local \ Google \ Chrome \ Application \ chrome.exe运行Chrome,即使手动尝试也无法运行。这很奇怪,因为当我启动Chrome时,我使用安装在Program Files目录中的一个,它没有问题。

So I had uninstalled Chrome, deleted everything from c:\Users______\AppData\Local\Google\Chrome\ and installed Chrome again. After that it started working.

所以我卸载了Chrome,删除了c:\ Users ______ \ AppData \ Local \ Google \ Chrome \中的所有内容,并再次安装了Chrome。之后它开始工作了。

#2


4  

I had the same problem as above. and I solved it. I run selenium with chromium in alpine. My environment:

我遇到了和上面相同的问题。我解决了我在高山中运行含铬的硒。我的环境:

  • Alpine (Linux 3.13.0-24-generic x86_64)
  • Alpine(Linux 3.13.0-24-通用x86_64)
  • Chromium 53.0.2785.92
  • 铬53.0.2785.92
  • chromedriver=2.22
  • chromedriver = 2.22
  • selenium (3.0.1)
  • 硒(3.0.1)

and I met the error information is:

我遇到的错误信息是:

File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error:    Chrome failed to start: crashed
(Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.13.0-24-generic x86_64)

My solution is run:

我的解决方案是运行:

apk add libexif udev

and Then it works.

然后它的工作原理。

I refer to here : https://hub.docker.com/r/rodrigomiguele/chromium/~/dockerfile/

我在这里指的是:https://hub.docker.com/r/rodrigomiguele/chromium/~/dockerfile/

#3


2  

  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.

这个示例代码对我来说很好用。只是一点注意:“chromedriver.exe”我放在同一个项目文件夹中。这使得chromedriver可执行文件的路径更容易。

So this line of code looks in this way:

所以这行代码看起来像这样:

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

Resource to download chromedriver.exe

资源下载chromedriver.exe

Hope this helps you.

希望这对你有所帮助。

#4


2  

Uninstall, delete chrome profile from c:\Users______L\AppData\Local\Google\Chrome\ and reinstall chrome will fix the problem, it worked for me

卸载,从c:\ Users ______ L \ AppData \ Local \ Google \ Chrome \删除chrome配置文件并重新安装chrome将解决问题,它对我有用

#5


1  

I fixed this on Windows 10 by setting chromedriver.exe, [yourPythonIDE].exe, and chrome.exe to run with Administrator rights, which can reached via right-clicking the exe file and going to Properties >> Compatibility.

我通过将chromedriver.exe,[yourPythonIDE] .exe和chrome.exe设置为以管理员权限运行来修复此问题,可以通过右键单击exe文件并转到属性>>兼容性来实现。

#6


0  

I had the same problem as above. Turned out I somehow managed to have two chrome.exe installed. One under Program Files and on under user\appdata\local..... I uninstall the one under Program Files and now it works like a charm.

我遇到了和上面相同的问题。原来我设法安装了两个chrome.exe。一个在Program Files下,在用户\ appdata \ local下...我卸载Program Files下的一个,现在它就像一个魅力。

#7


0  

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

通过使用Administrator CMD运行我的脚本,我能够在Windows 10上解决此问题。

#8


-1  

im pretty sure looking at your error that your bindings for chrome may not be right - please try removing all your references to chrome and removing it from your project. then, if you havent already, install Nuget Packet Manager and download chrome webdriver from there - note there are 2 one by chromium and one from selenium.

我非常肯定会看到你的错误,你的chrome绑定可能不正确 - 请尝试删除所有你对chrome的引用并从项目中删除它。然后,如果你还没有,安装Nuget Packet Manager并从那里下载chrome webdriver - 注意有2个来自铬,1个来自selenium。

hope this helps - let me know and if not ill take a closer look at it.

希望这会有所帮助 - 让我知道,如果不是生病,请仔细看看它。