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
Related
I run test in Jmeter with Selenium WebDriver Sampler
on Linux X86 and java SDK 11
The test run with 50 users.
I run it from the command line with non Gui mode and with Chrome headless mode.
but after 5 minutes the CPU going up to 100% and the memory almost full (8G).
What can I do to improve it?, I need run the test with 200 users and up.
Thanks,
Izik
You're expecting too much from your machine.
Although there are no specific RAM requirements defined at the Chrome System Requirements page, on my machine a single Chrome instance with a single tab in "porno" mode consumes almost 1GB of RAM. And this is given http://example.com page open, not modern web application with tons of JavaScript
I bet if you run the following command on your machine - you will get at least 3GB
(Get-Process chrome | Measure-Object WorkingSet -sum).sum
As per WebDriver Sampler tutorial
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
So my expectation is that you should be conducting the load using HTTP Request samplers and forget about using real browsers (or use 1 instance to collect client-side performance metrics). Just consider following recommendations from How to make JMeter behave more like a real browser article to ensure that protocol-based JMeter test has the same network footprint as real browser produces.
If you have to use real browsers for performance testing you won't be able to launch 200 browser instances on a machine with 8GB of RAM, you will have to find another 30-40 machines of this specifications and go for Distributed Testing.
This is expected, Since you are using Selenium it will use the JVM and browser which will consume a lot of memory. I would suggest you to distribute the test in multiple machine if you are going the Selenium route for load testing. This way you will be able to load test for more more number of users.
The best would be to stick to HHTP sampler as suggested above. You could also record and make necessary changes.
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.
I am creating recordings for a company website for performance tests. Normally this works fine though on occasion when starting a new test recording, HTTP Test Script Recorder will not record anything but returns the following error in the browser:
I have been using jmeter for a while now so I know the setup for HTTP Test Script Recorder is ok.
Clearing browser history, running in public or private mode doesn't help. Re-issuing jmeter proxy cert makes no difference either, the same for deleting proxyserver.jks.
Having experienced this before, I know that after a few days HTTP Test Script Recorder will start working again.
Happens for both jmeter v4 & v5.
I can think only of one situation when it can happen:
You have a JMeter test running in background (or a thread which failed to stop for some reason)
You're trying to record something at the same time
So
Make sure that nothing is running at the moment (you should see 0/0 in upper right corner of JMeter GUI)
Start clean recording session, to wit restart JMeter and create the test plan using Recording Template feature (From main menu choose File -> Templates -> Recording and click "Create"
Just in case be aware that you can also record your mobile application traffic using cloud-based proxy service, as a bonus you will get possibility to export recorded scripts in SmartJMX mode with automated detection and correlation of the dynamic parameters. Check out How to Cut Your JMeter Scripting Time by 80% article for more details if interested.
The issue you see is most probably a bug probably introduced by:
https://bz.apache.org/bugzilla/show_bug.cgi?id=57962
During recording, JMeter variables are null so we end up using an Unmodifiable version of them because of this:
https://github.com/apache/jmeter/blob/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java#L88
I suggest you open a bug here, providing as much information as possible:
https://jmeter.apache.org/issues.html
Provide:
How you reproduce it
The jmeter.log with the stacktrace (not as an image)
The workaround is to avoid running a test and recording after that.
Edit on 3 december 2018:
You reported a bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=62916
The reproducer is:
Start a distributed test where Controller is in GUI mode and a jmeter-server
Once test is finished, start a Recording using HTTP(S) Test Script Recorder
Hit a URL, you'll get the issue
The bug has been fixed today, it will be available in JMeter 5.1 and is already available in:
https://ci.apache.org/projects/jmeter/nightlies/
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.
I am currently using the jar of my selenium test suite to integrate with JMeter but, the problem which I am facing is that JMeter is opening the Firefox session equals to the number of threads which I specify because of that, my system gets unresponsive.
Does any one knows how to suppress multiple browser session to open on system without affecting the load testing?
It is normal each thread open his own browser... Maybe you can use phantomJS driver but ut will use memory too... Maybe not use this way and use recording controller to record scenario an play it directly with jmeter that is the stress test way the other not test the performance... You can use chrome headless too but cost memory too.. Another solution start new thread only when first thread us finish... I think with versiin 45 of firefox (only version working with jmeter) and jmeter 3.3 firefox not possible headless... Google an phantomJS yes possible.
The best solution use recorder controller.. Record a case and play it... Jmeter will use internal browser "system" low cost to achieve it dont forget that jmeter is stress test tool... You can use to do other action but not efficiently...