chromedriver.exe可运行约8个chrome.exe实例 [英] chromedriver.exe runs ~8 chrome.exe instances

查看:95
本文介绍了chromedriver.exe可运行约8个chrome.exe实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Selenium编写UI自动化测试.而且我注意到,当我创建chromedriver.exe的实例时->〜8 chrome.exe进程出现在任务管理器中.

I write UI automation tests using Selenium. And I noticed that when I create an instance of chromedriver.exe -> ~8 chrome.exe processes appear in the Task Manager.

运行1个测试时的任务管理器屏幕截图:

Task Manager screenshot when running 1 test:

所以,当我并行运行时,可以说有8个测试,任务管理器中有很多chrome.exe实例,它们使用一些端口并加载CPU和内存.

So, when I run in parallel, let's say, 8 tests there are a lot of chrome.exe instances in the Task Manager that use some ports and load a CPU and a memory.

它是按设计工作的吗?为什么一个chromedriver.exe需要那么多chrome.exe实例?这是可配置的吗?

Does it work by design? Why so much chrome.exe instances are needed for one chromedriver.exe? Is this configurable?

在我的代码中,我只有一个"Chrome"类.它的构造函数创建一个新的chromedriver.exe实例:

In my code, I just have a "Chrome" class. Its constructor creates a new chromedriver.exe instance:

Chrome chrome = new Chrome();

public class Chrome
{
    public OpenQA.Selenium.Chrome.ChromeDriver Driver;

    public Chrome(bool incognitoMode = false, bool maximizeWindow = true)
    {
        ChromeOptions options = new ChromeOptions();
        if (incognitoMode)
        {
            options.AddArguments("--incognito");
        }

        Driver = new ChromeDriver(options);
        Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(360);
        if (maximizeWindow)
            Driver.Manage().Window.Maximize();
    }
  /////////////////////////////////////////////
}

推荐答案

使用 Google Chrome浏览器执行自动测试时,您必须观察到可能有许多 Google Chrome 进程正在运行,可以通过Windows任务管理器的 Processes 标签查看.

When automated tests are executed using Google Chrome you must have observed that there are potentially dozens of Google Chrome processes running which can be observed through Windows Task Manager's Processes tab.

快照:

按照此文章以获得更好的用户体验 Google Chrome @Tests .Google尝试通过将每个网页分成它认为合适的多个进程来保持chrome浏览器的稳定,以确保如果某个进程在页面上失败,则可以终止或刷新该特定进程而无需终止或刷新该进程.整个页面.

As per this article for a better user experience Google Chrome initiates a lot of background processes for each of the TABS that have been opened by your @Tests. Google tries to keep the chrome browser stable by separating each web page into as many processes as it deems fit to ensure that if one process fails on a page, that particular process(es) can be terminated or refreshed without needing to kill or refresh the entire page.

但是,从2018年开始, Google Chrome 实际上经过了重新设计,以为以下每个实体创建新流程:

However, from 2018 onwards Google Chrome was actually redesigned to create a new process for each of the following entities:

  1. Tab
  2. 页面上的HTML/ASP文本
  3. 将这些插件插入
  4. 已加载的应用
  5. 页面内的框架

此外,在铬博客中被提及:

Google Chrome浏览器利用这些属性,将Web应用程序和插件与浏览器本身置于不同的进程中.这意味着一个Web应用程序中的渲染引擎崩溃不会影响浏览器或其他Web应用程序.这意味着操作系统可以并行运行Web应用程序以提高其响应速度,并且这意味着如果特定的Web应用程序或插件停止响应,浏览器本身将不会锁定.这也意味着我们可以在限制性沙箱中运行渲染引擎进程,以帮助限制发生漏洞利用时的损害.

Google Chrome takes advantage of these properties and puts web apps and plug-ins in separate processes from the browser itself. This means that a rendering engine crash in one web app won't affect the browser or other web apps. It means the OS can run web apps in parallel to increase their responsiveness, and it means the browser itself won't lock up if a particular web app or plug-in stops responding. It also means we can run the rendering engine processes in a restrictive sandbox that helps limit the damage if an exploit does occur.

结论是,您看到的许多过程都是设计好的,并且与 Google Chrome 的当前实施相一致.

As a conclusion, the many processes you are seeing is as designed and in-line with the current implementation of Google Chrome.

这篇关于chromedriver.exe可运行约8个chrome.exe实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆