简体   繁体   English

OpenQA.Selenium.WebDriverException:未知错误:Chrome 无法启动:通过 Selenium 执行测试时异常退出 start on linux

[英]OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux

I created an application that use Selenium using.NetCore for use it on Linux, actually this is my code implementation:我创建了一个使用Selenium using.NetCore 的应用程序,以便在 Linux 上使用它,实际上这是我的代码实现:

public class Program 
{
    public static async Task Main(string[] args)
    {
        //Settings for chrome
        var chromeOpts = new ChromeOptions();
        chromeOpts.AddArgument("headless");
        chromeOpts.AddArgument("no-sandbox");

        //Get assembly path where chrome driver is located
        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
        UriBuilder uri = new UriBuilder(codeBase);
        string path = Uri.UnescapeDataString(uri.Path);
        path = Path.GetDirectoryName(path);

        var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180));
    }
}

as you can see I am using as driver Chrome, I downloaded it here , I also added the driver inside the folder of the assembly, in this way the ChromeDriver knows already where to search it.如您所见,我正在使用 Chrome 作为驱动程序,我在这里下载了它,我还在程序集的文件夹中添加了驱动程序,这样 ChromeDriver 就知道在哪里搜索它了。

On linux I changed the folder permission using chmod -R 777 , but when I run my Do.net application I get this:在 linux 上,我使用chmod -R 777更改了文件夹权限,但是当我运行我的 Do.net 应用程序时,我得到了这个:

在此处输入图像描述

Seems that Selenium cannot start the application.貌似Selenium无法启动应用。 Looking at the Exception I get:查看我得到的异常:

Cannot find Chrome binary找不到 Chrome 二进制文件

Unfortunately I didn't find anything similar on the web, someone could help me?不幸的是,我在 web 上没有找到类似的东西,有人可以帮助我吗?

Thanks in advance.提前致谢。

UPDATE更新

I Just reinstalled Chrome on my linux machine and now the error above went away, but there is another problem now, infact I get this error:我刚刚在我的 linux 机器上重新安装了Chrome ,现在上面的错误消失了,但现在还有另一个问题,事实上我得到了这个错误:

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally  (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-130-generic x86_64)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)   
  at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)   
  at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)   
  at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)\   at ODS.Program.Main(String[] args)

This error message...这个错误信息...

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser ie Chrome Browser session. ...暗示ChromeDriver无法启动/生成新的WebBrowser,Chrome 浏览器会话。

Your main issue is the incompatibility between the version of the binaries you are using as follows:您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

  • You are using chromedriver=2.9 which is pretty ancient.您正在使用非常古老的chromedriver=2.9

So there is a clear mismatch between the ChromeDriver version ( v2.33 ) and the recent Chrome Browser version ( vVersion 68.0 )所以ChromeDriver版本 ( v2.33 ) 和最近的Chrome 浏览器版本 ( vVersion 68.0 ) 之间存在明显的不匹配

Solution解决方案

  • Upgrade ChromeDriver to current ChromeDriver v2.41 level.升级ChromeDriver当前ChromeDriver V2.41水平。
  • Keep Chrome version between Chrome v67-69 levels.Chrome版本保持在Chrome v67-69级别之间。 ( as per ChromeDriver v2.41 release notes ) 根据 ChromeDriver v2.41 发行说明
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client .如果您的基本Web Client版本太旧,请通过Revo Uninstaller卸载它并安装最新的 GA 和发布版本的Web Client
  • Execute your @Test .执行你的@Test

References参考

You can find a couple of relevant discussions in:您可以在以下位置找到一些相关讨论:

first, check your google-chrome version then download related chromedriver version ie首先,检查你的 google-chrome 版本然后下载相关的 chromedriver 版本即在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenQA.Selenium.WebDriverException:未知错误:Chrome 无法启动:在 CodeFresh 上异常退出 - OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: exited abnormally on CodeFresh C# OpenQA.Selenium.WebDriverException:“未知错误:无法创建 Chrome 进程。” - C# OpenQA.Selenium.WebDriverException: 'unknown error: Failed to create Chrome process.' OpenQA.Selenium.WebDriverException Message=无法在 http://localhost:port/ 上通过 C# 中的 Selenium 使用 ChromeDriver Chrome 启动驱动程序服务 - OpenQA.Selenium.WebDriverException Message=Cannot start the driver service on http://localhost:port/ using ChromeDriver Chrome through Selenium in C# OpenQA.Selenium.WebDriverException:'未知错误:ChromeDriver 仅支持 BMP 中的字符,同时通过 C# Selenium 发送表情符号 - OpenQA.Selenium.WebDriverException: 'unknown error: ChromeDriver only supports characters in the BMP while sending an emoji through C# Selenium OpenQA.Selenium.WebDriverException - OpenQA.Selenium.WebDriverException OpenQA.Selenium.WebDriverException:未知错误:a.tagName.toUpperCase 不是通过 Selenium 和 C# 带有 reactJS 元素的函数 - OpenQA.Selenium.WebDriverException : unknown error: a.tagName.toUpperCase is not a function with reactJS elements through Selenium and C# OpenQA.Selenium.WebDriverException Firefox无法启动 - OpenQA.Selenium.WebDriverException firefox won't start up 异常:OpenQA.Selenium.WebDriverException: - Exception :OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException: '无法在 http://localhost:60623/ 上启动驱动程序服务' - OpenQA.Selenium.WebDriverException: 'Cannot start the driver service on http://localhost:60623/' OpenQA.Selenium.WebDriverException:“无法在 http://localhost:20548/ 上启动驱动程序服务” - OpenQA.Selenium.WebDriverException: 'Cannot start the driver service on http://localhost:20548/'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM