Денис
Денис

Reputation: 1

How to use JavaScript global function in Jmeter

How can i use global javaScript function sellerInterface.addBidOnline() in JMeter? I can use this function in browser, but I do not know how to call it in JMeter.

Use in console

I try using this function in BSF Sampler, but it did not work

enter image description here

Upvotes: 0

Views: 463

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

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

If the JavaScript call generates a HTTP Request - you can record it using HTTP(S) Test Script Recorder and replay as HTTP Request sampler. For the time being it is not possible to execute JavaScript from JMeter tests.

You can take a look at WebDriver Sampler which provides JMeter integration with Selenium so each JMeter Thread (virtual user) will have its own real browser so you will be able to execute JavaScript like

WDS.browser.executeScript('your_script')

however real browsers are very resource intensive and the number of browsers you will be able to kick off will be very limited.

Upvotes: 1

Related Questions