Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does selenium chromedriver use less resources than regular chrome

I have noticed that when launching chrome with fresh user data directories via selenium chromedriver it is using up much less resources (cpu, memory, and disk) than when launching normally.

One of the reasons I was able to find out was that selenium chromedriver launches with these arguments:

--disable-background-networking
--disable-client-side-phishing-detection
--disable-default-apps
--disable-hang-monitor
--disable-popup-blocking
--disable-prompt-on-repost
--disable-sync
--disable-web-resources
--enable-automation
--enable-logging
--force-fieldtrials=SiteIsolationExtensions/Control
--ignore-certificate-errors
--log-level=0
--metrics-recording-only
--no-first-run
--password-store=basic
--test-type=webdriver 
--use-mock-keychain

After applying those arguments, cpu, memory, and disk usage have massively gone down. However, disk usage is still about 10x higher. Using Windows Resource Monitor, I analyzed the I/O usage and saw a lot of writing to chrome_url_fetcher directory and another directory with two random 5 digit numbers seperated by a underscore; RANDOMNUMBER_RANDOMNUMBER. Both of these directories were in the %temp% folder and contained files that included "pepperflashplayer" in their names.

I am assuming that this is chrome installing a necessary component for pepperflash, but why is this not the case with selenium chromedriver? Is there any way I can stop this?

like image 496
Carson Avatar asked Jan 25 '19 19:01

Carson


People also ask

Does headless Chrome use less memory?

Headless mode is not to run your program faster but headless mode makes your system memory utilization less and so better performance while execution. Since you are not opening the browser GUI, you can ignore the time taken by a normal browser to load CSS, JavaScript and render HTML.

What is the difference between Selenium WebDriver and ChromeDriver?

WebDriver is the Selenium library of code containing the FindBys and Clicks and SendKeys code. ChromeDriver is a library of code that controls the Chrome Browser. In order to create your test scripts, you need WebDriver. In order to control the Chrome Browser, you need ChromeDriver.

Can ChromeDriver work without Chrome?

The answer is No. You have to have the chrome application inside your computer.

Is Chrome and ChromeDriver same?

What Is ChromeDriver? A ChromeDriver is a separate executable or a standalone server that Selenium WebDriver uses to launch Google Chrome.


1 Answers

The Selenium driven ChromeDriver initiated google-chrome v87.0.4280.88 browsing context is initiated with these additional Command Line Switches:

  • --disable-background-networking: Disables several subsystems which run network requests in the background.
  • --disable-client-side-phishing-detection: Disables the client-side phishing detection feature.
  • --disable-default-apps: Disables installation of default apps on first run. This is used during automated testing.
  • --disable-hang-monitor: Suppresses hang monitor dialogs in renderer processes.
  • --disable-popup-blocking: Disables pop-up blocking.
  • --disable-prompt-on-repost: This switch may be used to disable that check that the user had attempted to navigate to a page that was the result of a post.
  • --disable-sync: Disables syncing browser data to a Google Account.
  • --enable-automation: Enables indication that browser is controlled by automation.
  • --enable-blink-features=ShadowDOMV0: Enables one or more Blink runtime-enabled features.
  • --enable-logging: Controls whether console logging is enabled and optionally configures where it's routed.
  • --log-level=0: Sets the minimum log level.
  • --no-first-run: Skip First Run tasks, whether or not it's actually the First Run.
  • --no-service-autorun: Disables the service process from adding itself as an autorun process.
  • --password-store=basic: Specifies which encryption storage backend to use.
  • --remote-debugging-port=0: Enables remote debug over HTTP on the specified port.
  • --test-type=webdriver: Type of the current test harness ("browser" or "ui" or "webdriver").
  • --use-mock-keychain
  • --user-data-dir="C:\Users\username\AppData\Local\Temp\scoped_dir9640_113432031: Directory where the browser stores the user profile.
  • data:,

The usage of these additional commandline switches makes the initialization of the Google Chrome process requires less callbacks as well as disables a lot more callbacks

Apart from that, Flash used by the regular chrome session is:

32.0.0.465 C:\Users\username\AppData\Local\Google\Chrome\User Data\PepperFlash\32.0.0.465\pepflashplayer.dll

Where as, Flash used by the ChromeDriver initiated chrome session is:

30.0.0.154 C:\WINDOWS\system32\Macromed\Flash\pepflashplayer64_30_0_0_154.dll

For the above mentioned reasons the ChromeDriver initiated Google Chrome is lighter and less memory consuming then the regular Google Chrome.

like image 77
undetected Selenium Avatar answered Nov 10 '22 23:11

undetected Selenium