简体   繁体   English

C# - Google chrome 在 docker Z0F4137ED1502B5045D2BAA8CZ 上运行 selenium 测试时崩溃

[英]C# - Google chrome is getting crashed when running selenium tests on docker windows

I am getting the following error when running selenium c# tests on docker windows.在 docker Z0F4137ED1502B5055D6083AA258 上运行 selenium c# 测试时出现以下错误。 Could anyone please help me on this.谁能帮我解决这个问题。 I am really struggling to get it solved.我真的很难解决它。

The Error that I am getting is shown below:我得到的错误如下所示:

OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
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 SeleniumCore.Core.Chrome.Initialize() in C:\src\SeleniumCore\Core\Chrome.cs:line 58

The code which initializes the chrome is shown below:初始化 chrome 的代码如下所示:

public class Chrome : IBrowser
{
public RemoteWebDriver MainDriver { get; private set; }

private readonly bool Headless;

    public Chrome(AppConfigContext context)
    {
        Headless = context.Headless;
    }

    /// <summary>
    /// Initialize Chrome Browser Instance.
    /// </summary>
    public void Initialize()
    {
        ChromeOptions options = new ChromeOptions();

        if (Headless)            
            options.AddArgument("headless");
            options.AddArgument("--disable-gpu");
            options.AddArgument("--no-sandbox");
            options.AddArguments("--disable-dev-shm-usage");

        var downloadPath = Controls.DataFilePath + @"Downloads";

        Controls.CreateDirectory(downloadPath);

        options.AddUserProfilePreference("download.default_directory", downloadPath);
        options.AddUserProfilePreference("download.prompt_for_download", false);
        options.AddUserProfilePreference("disable-popup-blocking", "true");



        RemoteWebDriver driver = new ChromeDriver(@"C:\Chromedrivers\new",options);
        MainDriver = driver;

The docker info which I am using:我正在使用的 docker 信息:

Client:客户:

Context: default上下文:默认

Debug Mode: false调试模式:假

Plugins:插件:

buildx: Docker Buildx (Docker Inc., v0.7.1) buildx:Docker Buildx(Docker Inc.,v0.7.1)

compose: Docker Compose (Docker Inc., v2.2.1)撰写:Docker 撰写(Docker Inc.,v2.2.1)

scan: Docker Scan (Docker Inc., v0.14.0)扫描:Docker 扫描(Docker Inc.,v0.14.0)

Server:服务器:

Containers: 5容器:5

Running: 0运行:0

Paused: 0暂停:0

Stopped: 5停止:5

Images: 50图片:50

Server Version: 20.10.11服务器版本:20.10.11

Storage Driver: windowsfilter存储驱动程序:windowsfilter

Windows: Windows:

Logging Driver: json-file日志记录驱动程序:json 文件

Plugins:插件:

Volume: local音量:本地

Kernel Version: 10.0 19042 (19041.1.amd64fre.vb_release.191206-1406) Kernel 版本:10.0 19042 (19041.1.amd64fre.vb_release.191206-1406)

Operating System: Windows 10 Pro Version 2009 (OS Build 19042.1466)操作系统:Windows 10 Pro 版本 2009(操作系统内部版本 19042.1466)

OSType: windows操作系统类型:windows

Architecture: x86_64架构:x86_64

CPUs: 4中央处理器:4

Total Memory: 7.886GiB总 Memory:7.886GiB

Name:姓名:

Labels:标签:

Experimental: false实验:错误

Insecure Registries:不安全的注册表:

127.0.0.0/8 127.0.0.0/8

Live Restore Enabled: false启用实时恢复:假

Product License: Community Engine产品许可证:社区引擎

Please reply for this.请对此作出答复。 Thank you谢谢

If your usecase is to connect to the RemoteWebDriver , instead of:如果您的用例是连接到RemoteWebDriver ,而不是:

RemoteWebDriver driver = new ChromeDriver(@"C:\Chromedrivers\new",options);

You have to:你必须:

var MainDriver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.Chrome()); // replace this url with the url of your remote hub

暂无
暂无

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

相关问题 运行 C# Selenium 测试时获取 System.ArgumentException - Getting System.ArgumentException when running C# Selenium Test 如何在作为 Windows 服务运行的 Jenkins 上以无头模式使用 Firefox 运行 Selenium 测试(C#、.NET) - How to run Selenium tests (C#, .NET) with Firefox in headless mode on Jenkins running as Windows service 使用Selenium WebDriver和NUnit C#在Parallel中运行测试后,如何关闭多个浏览器窗口 - How to close down multiple browser windows after running tests in Parallel using Selenium WebDriver and NUnit C# 在硒网格上运行测试时无法调整Chrome窗口大小的大小 - Unable to resize the chrome window size when tests running on selenium Grid 在C#selenium测试运行时打开Goog​​le Chrome开发人员工具控制台,或以编程方式阅读 - Open Google Chrome developer tool console while C# selenium test is running, or read it programmatically 运行某些特定测试时vstest崩溃 - vstest crashed when running some particular tests Selenium C# / NUnit 3.12.0 未并行运行测试 - Selenium C# / NUnit 3.12.0 is not running tests in parallel 使用Gallio和Powershell和Chrome Driver在MbUnit框架和Selenium中进行C#并行测试失败-所有测试均失败 - Failed Parallel tests in C# with MbUnit framework and Selenium using Gallio and powershell with the Chrome Driver - all tests fail 在Chrome中滚动页面时,无法使用Selenium C#填充元素 - Elements not getting populated using Selenium C# with page scrolling in Chrome Browserstack中的Selenium C#测试 - Selenium C# tests in Browserstack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM