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?
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.
Related
Recent versions of Firefox do some background accesses to websites that are immediately aborted. (it's related to some IPv4/IPv6 decision or similar)
I am developing a web application and those probes spam my logs (each prints a multi-line stack trace)
Is there a setting in Firefox to turn this probing off?
This is a Firefox feature called Race Cache With Network .
Short description: Firefox sends requests for cached resources concurrently to the local disk cache and the actual network server. Whichever result arrives first is used - the other request is canceled.
The idea is that sometimes the network is faster that the cache on HDD, so this way the page is loaded faster.
To turn it off, open about:config and set network.http.rcwn.enabled to false.
Sources:
Race Cache With Network experiment on Nightly (dev-platform mail list)
primefaces.org forum post
Test connections in background mozillaZine forum
I tried to use the all jmeter's drivers to create headless browser, but unfortunately without success. HtmlUnit Driver works, but doesn't run the javascript, when i run the both Chrome and PhantomJs drivers, i getting the Exception:
java.lang.IllegalArgumentException: Browser has not been configured. Please ensure at least 1 WebDriverConfig is created for a ThreadGroup.
Below my Phantom and Chrome configurations:
Looking into the error you're getting it seems that your Chrome Driver Config and/or PhantomJS Driver Config are not enabled, you need to make the Config element active via Edit -> Toggle menu or pressing Ctrl+T.
Be aware that you can run in fact any browser in headless mode, on Linux you can use virtual framebuffer and on Windows you can just run JMeter as LocalSystem account. Check out Headless Execution of Selenium Tests in Jenkins guide for comprehensive instructions.
Also be informed that even in headless mode real browser footprint in terms of CPU and RAM usage will still be immense so I wouldn't recommend using real browsers for creating the main load, you should stick to JMeter's HTTP Request samplers instead and if needed use single real browser instance via WebDriver Sampler integration for client-side performance checks.
I found the solution myself. If the machine with Jmeter on linux, you should give the permissions to run the executable:
chmod 755 "path to you driver executable file"
Thanks to: https://stackoverflow.com/a/40556732/5279455
I've got the following totally reproducible scenario, which I'm unable to understand:
There is a very simple application, which does nothing else than calling CreateObject("Word.Application"), that is creating an instance of MS Word for COM interop. This application is located on a Windows Terminal Server. The test case is to connect via RDP, execute the application and the application will output the time taken for the CreateObject call.
The problem now is that the execution time is significantly longer, if I connect from a specific notebook (HP Spectre): It takes 1,7s (+/- 0.1s).
If I connect from any other machine (notebook or desktop computer), then the execution time is between 0,2-0,4s.
The execution times don't depend on the used RDP account, or screen resolution, or local printers. I even did a fresh install of Windows on that HP notebook to rule out any other side-effects. It doesn't matter if the HP notebook is connected via WLAN or an USB network card. I'm at a loss understanding the 4x to 8x execution time difference to any other machine.
Which reason (component/setting) could explain this big difference in execution time?
Some additional information: I tried debugging the process using an API monitor and could see that >90% of the execution time is actually being spent between a call to RpcSend and RpcReceive. Unfortunately I can't make sense of this information.
It could be the credential management somehow being in the way.
Open the .rdp file with notepad and add
enablecredsspsupport:i:0
This setting determines whether RDP will use the Credential Security Support Provider (CredSSP) for authentication if it is available
Related documentation
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ff393716%28v%3dws.10%29
According to your information about RpcSend and RpcReceive time consumption, it could be the case you have some service stopped on your client machine, like DCOM server or some other COM-related (they usually have "COM" or "transaction" in their names).
Some of that services could be started/stopped (if Manually mode selected) by system to/after transfer your request, but there is a time delay to starting service.
I suggest you to open Computer Management - Services or run -> services.msc and compare COM-related services running on your "slow" client and on your "fast" clients, and try to set Automatically running instead Manually or Disabled.
Also, try to run API Monitor on such processes to determine the time-consuming place more precisely.
I am running a Selenium WebDriver test in the Remote Desktop using maven command. The test is taking very long time to load the URL and login into the site whereas when I try to run the same test in my local both URL loading and user Login where very quick. Can someone please tell me what would be the reason for that slowness.
In my experience using Remote VM as UI tests host, has always been slower compared to local environment. Mainly because the dedicated VMs are missing the GPU and they try to render the requested browser(s) through the CPU. If you open your remote machine monitoring tool, most likely you'll see a lot of spikes when the browser launches. Similar to the one shown bellow.
In order to optimize performance, you can employ headless execution (HtmlUnitDriver, PhantomJS) or block certain content from loading, like images, animations, videos etc. However when doing this, try to keep their placeholders.
As far as i understand, there are two possible ways of setting up a selenium server (just a node) on windows:
As a windows service
Using the task scheduler to start the server running within a local user account
However, using the service way (where no desktop is available) the Internet Explorer can not be used.
Therefore, i created a local user account and a scheduled task to start the selenium server at startup connected to the user account (using the selenium-standalone package, selenium-standalone start --drivers.ie.arch=ia32).
Unfortunately, i ran into the "Session 0" problem, which requires a real login for the local user account. Otherwise, i would receive a timeout error for
Chrome and black screenshots for IE and have the max resolution of 1024x768...
However, with a active user session, i still get the timeout error for IE (Chrome works). The browser makes the initial GET request (retrieving the login page) but keeps stuck after this (next step would be to fill the form with credentials using protractor).
I read about the Headless Selenium for Windows that gives me some connecting layer between the driver and the GUI. Though, i do not know if this would help and how to integrate this into the selenium-standalone package.
So, my question is, what is the missing puzzle in the setup?
I would suggest you to move away from Session 0, as Chrome is trying to move away from Session 0 too in the near future.
You can find further references of this here (comment 21 in the link below, but actually the whole thread is a good read in respect to this subject): https://bugs.chromium.org/p/chromium/issues/detail?id=615396#c21
You could try using this setup for Chrome for now, however there is no guarantee that it will still work while Chrome is started Session 0.
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("test-type");
chromeOptions.AddArguments("--disable-extensions");
chromeOptions.AddArguments("no-sandbox");
var driver = new ChromeDriver(chromeOptions);
I had the same issues with using Microsoft's Test Agent, and moving the agent from a windows service to a process, solved all the issues and headaches that I had.
As stated above, there are two ways to accomplish the setup. However, only with using a scheduled task i was able to workaround the session 0 issue (as #Cosmin stated). Using NSSM and FireDeamon Pro was a dead end.
I reconfigured the server, to automatically login the local user account and changed the scheduled task, to run if and only if this user is logged in (starting Selenium). So, after the server starts, the user gets logged in, which triggers the task scheduler (at this point a simple startup script should work, too) to start Selenium.
And for the screen resolution problem: The VM setup uses Hyper-V, where the default resolution is 1024x768. This could easily be changed (to the max resolution the screen adapter is providing) to 1600x1200.
PS: The Headless Selenium for Windows did not work either (can not be used with Protractor). However, even this is no longer necessary. IE works this way.