Javascripts in jMeter response of SPA - jmeter

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.

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 give error "We are sorry but vue-dms-ui-component doesn't work properly witouth Javascript enabled.Please enable it to continue"

In Jmeter, I have used "Recording with Think Time" for an application. Now when i run, in the Response I get message "We are sorry but vue-dms-ui-component doesn't work properly witouth Javascript enabled.Please enable it to continue".
I get this message for all the requests. I have enabled JavaScript in Firefox and then captured the recording.
Attaching the screenshot of the message.
enter image description here
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 it's not possible to "enable" JavaScript in JMeter.
If JavaScript is being executed on client-side only you can simply ignore this
If JavaScript generates a single network request - you need to mimic it using HTTP Request sampler
If JavaScript generates more than 1 network request at a time - use as many HTTP Request samplers as there are AJAX requests and put them under the Parallel Controller
Don't forget to perform correlation of dynamic parameters as in the vast majority of cases you cannot just replay the recorded network traffic.

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

Is it possible to pass Keys.TAB or Keys.Slash using Jmeter through groovy script?

Is it possible to pass Keys.TAB or Keys.Slash using Jmeter HTTP request through a groovy script?
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 pressing tab or slash triggers a network request to your server - you can mimic it by sending the corresponding HTTP Request via HTTP Request sampler. You can check whether pressing a key generates network activity by looking at "Network" tab of your browser developer tools
If pressing a key doesn't generate a HTTP request - you won't be able to test this scenario using JMeter, you will need a real browser driven by the browser automation framework like Selenium. JMeter can be integrated with Selenium via WebDriver Sampler

Performance test on a webpage which loads data from multiple API's

We have a webpage which will load data from multiple api's as configured by the users. While doing performance test of this page, In HTTP request I have added this page URL and executed the script. To my surprise, the script executed successfully with status as 200 as I dig into more I changed the drop down(In View Results Tree) from Text to HTML(Download Resources) and I don't see any page data in the response. Can someone help me with this. I'm not sure how to proceed with performance testing on this particular page.
As per JMeter project main page:
JMeter is not a browser
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).
My expectation is that your "multiple APIs" are triggered by JavaScript calls using AJAX technology. Given JMeter doesn't evaluate JavaScript it doesn't execute the AJAX requests which are being called by the real browser therefore you don't see the data coming from the APIs.
In order to get the browser-like behaviour you need to send the same requests which real browser sends, you can record them from the real browser using HTTP(S) Test Script Recorder or JMeter Chrome Extension
Also be aware that real browsers execute AJAX requests in parallel, in order to properly simulate browser's network footprint you need to place the HTTP Request samplers representing these API requests under the Parallel Controller

Resources