Recorded script by blaze Meter & browser is showling all cookies but JMeter is not i.e. ai_user & ai_session, how do I get those cookies values? - session

Browser shows all cookies when we hit home request
These are the cookies that appear in browser when we execute home page 1st time, but not in Jmeter request
Its JMeter response that shows cookies
My issue is when I execute home page in browser it shows all cookies 1st time when we hit request but in JMeter home request don't show up all cookies as shown in picture.
I want cookies values i.e. ai_user & ai_session and pass them to UserSessionId & AppSessionId in HTTP request header. So how do I get those values? I already user HTTP CookiesManager in my script to handle cookies but can't get ai_user & ai_session cookies values.

Given you send the same request in JMeter as in the real browser you should get the same response so double check all the request details like:
URL
Headers
Body
etc.
Try using clean browser session or at least private mode
Look at Set-Cookie header for the first request and see if the cookies you're looking for are there. It might be the case that the cookies are being set by JavaScript and 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 if this is the case you will need to mimic the JavaScript code logic using JSR223 PostProcessor or just extract the values from the response if they are there using other suitable Post-Processor

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 send requests that are not on my request list

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

Jmeter | PerformanceTesting | Cookie Manager Issue

I have recorded using jmeter and enhanced the script but facing a redirected response as below:
Object moved
Object moved to here.
I tried using Cookie manager and also correlated viewstate and viewgenerator still facing a object moved error
Try playing with "Redirect automatically" and/or "Follow redirects" checkboxes in the HTTP Request sampler
the idea is to make JMeter to behave exactly like a real browser so cross-check the requests JMeter is making with the requests from the "Network" tab of your browser developer tools
As the last resort you should be able to extract the redirection URL from the Location header using Regular Expression Extractor and configure the next HTTP Request sampler to hit this URL.

JMeter can't find token in any response

I'm trying to record a script in JMeter. I'm getting a 401 error in the login request. I see that the login request is sending a token to the server and I have to correlate this token however I'm not able to find any token in the response body or response header of any previous request. What should I do?
There are 4 sources where the "token" could come from:
Response body
Response headers (including cookies)
URL (as a result of a redirection), if this is the case you might need to play with Redirect Automatically and Follow Redirects checkboxes in the HTTP Request sampler (or HTTP Request Defaults)
The token can be generated by JavaScript. 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 if this is the case - you will have to replicate the logic of the associated JavaScript function(s) using JSR223 PreProcessor

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.

Resources