Jmeter send requests that are not on my request list - jmeter

I noticed this when analyzing wireshark. under thread group those requests are:
homepage/Account/Login
homepage/
homepage/LiveAlarm
and so on.
on wireshark there are some other requests that jmeter sends. but when i test this with browser, that requests wont be send.
after request 2)
HTTP GET /Content/css?v=........... HTTP/1.1\r\n
HTTP GET /Content/cus-css-plugins?v=......-..... HTTP/1.1\r\n
HTTP GET /images/logo/logo.._...png HTTP/1.1\r\n
and so on, totally 6 inintended requests are sent. there are not in the sampler list. and not sent when using browser.
the test script is recorded by blazemeter chrome plugin.
another unintended request
HTTP GET /signalr/hubs HTTP/1.1\r\n is sent by jmeter, but it is also sent when using browser.
because it is not in the sample list, the "Accept" field is very different between browser and jmeter. it is another issue. so, should i add this request to jmeter manually and control the fields?

BlazeMeter Chrome Extension generates a JMeter Test Plan with HTTP Request Defaults configuration element configured to "Retrieve Resources from HTML Files"
This is normal as it replicates real browser behaviour, real browsers download the HTML content from the response and then execute parallel HTTP Requests to download images, scripts, styles, fonts, sounds, etc. and this setting instructs JMeter to behave like a real browser when it comes to these embedded resources handling.
If you open your browser developer tools you should see the same requests (just tick "Disable cache" if you don't see them)
More information: Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses

Related

504 Gateway timeout in Jmeter

During manual run on reaching the Home screen, the page keeps loading and the API calls timeout with 504 error(Received the same error during Jmeter execution)
But if the same page(Home screen) is refreshed three times manually, all the previously timed out APIs load successfully (status:200).
But I'm unable to identify how to refresh the page using Jmeter. Any help on this? Thanks!
I tried adding JSR223 preprocessor with the following Javascript -
load("API-url") in the script section but it doesn't seems to work.
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 in order to "refresh" the page you need to send the same HTTP Request to it using HTTP Request Sampler. If you want to send the same request more than once it makes sense to put in under the Loop Controller
Also given the above quote from JMeter documentation if loading the page triggers some AJAX requests to the API - JMeter won't execute these requests automatically, you will need to create a separate HTTP Request sampler per API request. Also real browsers execute AJAX requests in parallel so if there is more than 1 API request - you need to put them under the Parallel Controller

Jmeter Report:-How to download response parallel like browser jmeter shows by adding all sub url responses

Jmeter Report: How to download response parallel like browser? Suppose i have 4 request in one transaction controller and i want to get response parallel for all request instead of sequentially.
In my transaction controller 4-5 http request are present and i want to download response of all request parallel instead of sequential.
In report all response are added and then showing but when we are using browser response are showing by subtracting the depended or complete responses.
If you're talking about "embedded resources" - images, scripts, styles, fonts, etc. - you should not be adding requests for them manually, instead you need to configure HTTP Request Samplers to do this for you (or even better HTTP Request Defaults). The relevant settings live under "Advanced" tab:
If the nature of the requests is different, i.e. they're AJAX requests which are not supported by JMeter out of the box the easiest way of executing them at the same moment is placing them under the Parallel Controller. It is not a part of JMeter distribution bundle and can be installed using JMeter Plugins Manager

Javascripts in jMeter response of SPA

I am doing automation using API testing for mobile app.
There are 3 different home screens on app.
Workflow-
1)Login- Sending login API request & in response getting access token which is used in further requests.
2) Screen1-Sending API request on screen1 & getting response -Success
3) Screen2 -sending API request on screen2 & but its not working .It sends 3-4 .js(javascripts) files in response. Screen2 is Single page application. Jmeter does not execute those js from response hence no content seen.
I am blocked here & cant proceed .Any pointer ...appreciated.
First of all check whether JMeter is configured to download embedded resources. You can do it on "Advanced" tab of the HTTP Request sampler (or better HTTP Request Defaults)
If this box is unchecked - JMeter will return only main content but will not process any so called "embedded resources": images, fonts, scripts, styles which are referenced by the webpage.
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
So if there is a JavaScript somewhere in the response which triggers an AJAX request which returns your "js" files - JMeter won't execute it automatically, you will need to add a separate HTTP Request sampler(s) to mimic the AJAX call(s)
None of the load testing tools is capable of executing JavaScript so if you looking for a one - you need to consider real browsers. For example check out JMeter integration with Selenium via WebDriver Sampler, but be aware that this approach is very resource intensive.

How to execute Ajax requests in JMeter?

I want to execute Ajax requests in JMeter. I record my test plan with JMeter and BlazeMeter but none can handle Ajax requests. How can I solve my problem?
Or is there any tool that can send concurrent Ajax requests?
Thanks in advance,
M.A
By default, Ajax requests can't be simulated by JMeter as it does not process .js files (As of 3.1 version). You have to explicitly add the requests (HTTP Samplers) for AJAX requests.
Use Network tab of a browser (F12 option) and filter the traffic by xhr, which shows only AJAX requests. Add those requests as HTTP Samplers in the script at the point you needed in the Test Plan.
Browser can process .js files, hence AJAX requests are sent from the browser. When you record the script using HTTP Test Script Recorder, as you are using the browser to navigate, even AJAX requests (originated from js files) will also be added/recorded to the Test Plan.
Since JMeter can't process .js files due to limitation, manually add the AJAX requests (nothing but HTTP Get or Post requests) using HTTP Sampler, if you are building the Test Plan without HTTP Test Script Recorder.
Note: If you are using HTTP Test Script Recorder, no need to add them manually as they are already recorded in the Test Plan.
you can do that by recording http traffic with JMeter Proxy
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
but it is only possible to replay the same traffic, can be problematic for sessions, cookies...
Better solution is to use WebDriver
https://jmeter-plugins.org/wiki/WebDriverTutorial/
https://jmeter-plugins.org/wiki/PluginInstall/
the needed package is https://jmeter-plugins.org/files/packages/jpgc-webdriver-1.4.0.zip
It is not possible as kicking off more threads than originally defined in the Thread Group is not currently supported, the feature is being tracked as Bug 53159. AJAX requests are "normal" HTTP Requests so JMeter can record and replay them, but when it comes to asynchronous execution - you cannot do this as of now. The workaround options are in:
Use WebDriver Sampler plugin so each JMeter virtual user will kick off a real browser. Warning: this way is very resource intensive.
Use scripting, i.e. JSR223 PostProcessor to kick off AJAX-driven requests via Apache HttpComponents
Develop your custom sampler. You can use the current way of handling embedded resources as a reference.
Learn more: How to Load Test AJAX/XHR Enabled Sites With JMeter
I had this same problem after recording samplers using the JMeter Proxy. The answer was on this blog post: https://lincolnloop.com/blog/load-testing-jmeter-part-1-getting-started/ - see the Ajax Requests section.
Add an HTTP Header Manager for the ajax request and make sure you are sending the X-Requested-With:XMLHttpRequest header.

What is the indication of Result as Cache in httpfox

I am getting Result as Cache for particular request in Httpfox and type as application/json
Real browsers download embedded resources like images, scripts, styles, asynchronous requests results, but do it only once. During subsequent requests aforementioned entities are being returned from the browser cache.
JMeter provides HTTP Cache Manager in order to simulate above behavior.
I think that you might also like to add the following test elements to your test plan to make your JMeter test even more realistic:
HTTP Cookie Manager - to represent browser cookies
HTTP Header Manager - to send browser headers like User-Agent
Configure HTTP Request Defaults to download embedded resources using thread pool as per How to make JMeter behave more like a real browser guide

Resources