2

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.

Task Manager screenshot when running 1 test:

Screenshot Task Manager

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.

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

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();
    }
  /////////////////////////////////////////////
}
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Denys
  • 43
  • 1
  • 6
  • 1
    This is how Chrome behave. You will see the same even if you open the browser manually. – Guy Oct 23 '19 at 09:20
  • @DebanjanB, yeah, you are absolutely right! I just thought that the Chrome browser and chromedriver.exe have some differences. Thank you! – Denys Oct 23 '19 at 12:57

1 Answers1

5

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.

Snapshot:

GoogleChrome_processes

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.


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 text on the page
  3. Plugin those are loaded
  4. App those are loaded
  5. Frames within the page

Further, in a Chromium Blog it is mentioned:

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.

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352