0

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.

Crose
  • 1
  • 1

1 Answers1

0

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

Dmitri T
  • 159,985
  • 5
  • 83
  • 133