Calling application javascript function - jmeter

coSelectAll();
coUnSelectAll();
These function above are part of our application and when I run on chrome console it select and unselect a company structure. How can I call these functions from jmeter as I heard jmeter does not have access to DOM. I am a newbie so forgive me if this is a silly questions. What options are available in jmeter.

If these functions generate HTTP Requests you should be able to record and replay them using JMeter's HTTP(S) Test Script Recorder.
If these functions affect UI only (i.e. check some boxes or something like that) you won't be able to do test it using JMeter, as per JMeter project main page
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages.
Real browsers send HTTP Requests and render the response. JMeter can mimic sending any HTTP requests via HTTP Request samplers so from application under test perspective it won't be different from real user, but JavaScript is executed solely on client side so if it doesn't trigger any network activity - the server doesn't know anything about what is happening in the browser on client side.
If your test scenario assumes checking selection/deselection of company structure via invoking certain JavaScript functions consider switching to Selenium browser automation framework. Also be aware that there is a Selenium integration with JMeter via WebDriver Sampler.

Related

Important - Jmeter -UI endpoint - response time deferring from developer tool response time

For performance testing testing Jmeter UI - endpoint - response time deferring from developer tool loading time
Ex Jmeter - endpoint response time is 615 Ms where in developer tool shows (Load: 13.30 s) Finish: 18.98 s
Note : Jmeter capturing 35 backend call/ Developer tool capturing 104 backend call
why jmeter couldn't capture all developer tool backend calls?
why jmeter couldn't capture all developer tool backend calls? do we have any solution for this issue
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So apart from configuring JMeter to behave like a real browser when it comes to handling embedded resources, cookies, think times and so on you need to pay attention to the nature of the requests which are being called when you open the page in the browser.
If the request is created by JavaScript, i.e. it's an AJAX call JMeter won't make the request automatically when you open the page. However you can record it using JMeter's HTTP(S) Test Script Recorder and run after the main request. The cumulative response time can be measured using Transaction Controller
Check the Retrieve All Embeded Resources in Advanced tab of the http sampler and see what is the difference.
Times will be always slightly different between dev tools and Jmeter or between JMeter and other performance tools like Gatling for example.

Jmeter: Active Browser Tab

Running Jmeter on a service whereby there is Duo MFA (with MFA being bypassed). The Duo MFA page bypasses only if in active browser tab. Would there be a way for Jmeter to mimic active browser?
Most probably your "Duo MFA" (whatever it is) is using JavaScript for detecting whether its being run in the browser and maybe even by human (i.e. it has bot-detecting heuristics)
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So I don't think that it is possible to "bypass" this real browser check without kicking off a real browser.
The options are in:
Ask your application developers/devops/whoever is responsible for the infrastructure to turn off this MFA as your test should focus on your application and not on external resources/dependencies
Use a real browser for bypassing it, for example WebDriver Sampler plugin provides JMeter integration with Selenium browser automation framework. Once you are let in you can transfer cookies from the browser into JMeter's HTTP Cookie Manager and continue using normal HTTP Request samplers
Try to reverse this "browser" check by inspecting the traffic which is going back and forth between your browser and this Duo MFA backend, if you'll manage to decrypt it - you should be able to replicate it so Duo MFA will think that you're using the browser, however I'm not sure that it's easily doable and legal

My Jmeter Webdriver sampler test is too heavy on my machine. I'm planning to use selenium grid, with selenium grid ,will it make my test more lighter?

My Jmeter Webdriver sampler test is too heavy on my machine. I'm planning to use selenium grid, with selenium grid ,will it make my test more lighter? As of the moment while running my test on gui and non gui mode I'm encountering a web driver timeout , connection timeout, and an out of memory error. Will this approach help?
Have you tried to read WebDriver Sampler's documentation?
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.
You should not be creating the main load using WebDriver Samplers, 99.99999% of the virtual users should be simulated on HTTP protocol level, WebDriver Sampler could be used only for specific use cases like OAuth login, checking client side performance, etc.
Check out How to make JMeter behave more like a real browser article to learn how to properly setup JMeter for web applications testing so it would generate the same network footprint as the real user using the real browser.
If your have a form of a strict requirement to use the real browsers - consider switching to Distributed Testing as in case of Selenium Grid you will not be able to collect samplers execution metrics precisely.

Jmeter - How to load test ajax web applications by multiple users with cache

I have been using Jmeter for performance testing my web application. I have recorded the jmeter script by excluding js,css and other static content files.
While running the script, Jmeter doesnt execute javascript files so ajax XHR request are not sent. To overcome this i have recorded the script with js, css and other static content and it recorded all the Ajax xhr request too. But the performance results seems to be different from the browser loading time. Also i need to use cache during my performance testing.
Below is how my test plan will look like,
Included Retrieve all embedded resources in HTTP Request manager.
Concurrent pool size is 6
I have added HTTP cookie manager and Cache manager.
I have added a loop controller (This is for caching, jmeter will cache the files on first iteration and it will use the cached files
after that)
The problem i am facing is that the time taken for rest call are double the time shown in the browser console for single user. I have tried all other combinations but always i am getting higher time than the browser console.
I have tried to use the Selenium webdriver plugin to simulate the browser behavior but it doesnt seems to be using the cache. (https://www.blazemeter.com/blog/how-load-test-ajaxxhr-enabled-sites-jmeter)
Is there any other way to solve this problem? I want to take the metrics with cache so kindly suggest me any solution that must include cache. Or is there any other tool similar to jmeter that could solve this issue. My goal is to take web page load time with cache for 'n' number of users.
PS : I am even interested to write any scripts in jmeter but the scripts should not overload the performance of jmeter.
Thanks in advance.
You should not be recording calls to embedded resources (images, scripts, styles, fonts, etc.) as if you record them - they will be executed sequentially while real browsers do this in parallel. So remove recorded requests for the embedded resources and "tell" JMeter to download them (and do it in parallel) using HTTP Request Defaults
You should be recording AJAX requests, however real browsers execute them in parallel while JMeter runs them sequentially. In order to make JMeter's behavior closer to real browser you need to put these AJAX calls under the Parallel Controller
You can install the Parallel Controller extension using JMeter Plugins Manager
Jmeter and caching are unrelated - everything that happens after data went over the wire is out of scope by design. You should only ever simulate requests that you expect NOT to be cached. So this is the feasible part: drop all requests that you expect the browser to cache from the Jmeter script (or move them outside the loop). On the load time of XHR: the browser will most certainly use HTTP keepAlive. Result is that all requests except the very first skip the setup and teardown phase of TCP sockets and are much faster - esp. when the request itself is small and quick. You can simulate this in JMeter also by checking the KeepAlive option AND selecting http commons as implementation. You can read up on this in the docs here: http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request

Finding End user response time in Jmeter

How can we capture the end user response time in JMeter?
If there is any plug-ins available?
Can u please help me.
As per the main page of the Apache JMeter project
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time)
Well-behaved JMeter test acts quite similarly to read users using real browsers given you properly handle embedded resources, cookies, headers, cache, AJAX calls, etc. See How To Make JMeter Behave More Like A Real Browser article for JMeter tuning recommendations.
I would also recommend using i.e. YSlow or WebDriver Sampler to measure real life user experience while the main load is being conducted using JMeter, this way you will be able to get more precise picture.

Resources