Pankaj
Pankaj

Reputation: 31

How to enable JS on jmeter while doing performance testing

I need to do performance testing while i doing same thing on jmeter

i am doing performance testing on my website. and error display "Please turn JavaScript on and reload the page". so can you please guide me how can i enable JS through jmeter ?

Upvotes: 1

Views: 2687

Answers (1)

Dmitri T
Dmitri T

Reputation: 168082

You cannot.

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).

I can think of 3 possible ways of dealing with JavaScript:

  1. It's executed on client side (in browser) and doesn't generate a network request. If this is the case you can simply ignore it as you're testing the backend, not the client. If you need to test client-side performance JMeter will not help due to the aforementioned reasons, consider using browser automation tool like Selenium or if you use JMeter as the global framework there is WebDriver Sampler plugin which provides JMeter integration with Selenium
  2. If JavaScript produces one or more HTTP Requests - in order to make your test to behave more like a real browser you should be executing the requests. Although JMeter cannot parse JavaScript it's capable of recording JavaScript-originated HTTP Requests via HTTP Request sampler. In case if there is more than one request, i.e. application is built on AJAX technology it's better to put the HTTP Request samplers under the Parallel Controller cause real browsers execute AJAX request more or less at the same time
  3. JavaScript is used to generate some essential request parameters, cookies, headers, etc. If this is the case you will need to understand what JavaScript code is doing (you can debug it using your favorite browser developer tools) and re-implement the code using JSR223 Test Elements and preferably Groovy language.

Upvotes: 2

Related Questions