Reputation: 3439
I need to get the local storage of Jmeter inside the Jmeter as a variable so i can use it for the further authentication. I have added Cache manager but it does not help. I have done some research but it does not help.
Any help will be appreciated Thank you.
Upvotes: 1
Views: 3527
Reputation: 168082
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).
And according to Window.localStorage description:
The read-only localStorage property allows you to access a Storage object for the Document's origin
The Document in its turn:
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.
As JMeter cannot execute JavaScript you don't have access to the Document and Window objects hence you cannot get anything from the localStorage
The only way working with JavaScript and getting values from the local storage is using WebDriver Sampler which provides JMeter integration with Selenium browser automation framework which in its turn can control real browsers and execute arbitrary JavaScript so this way you can access localStorage and extract necessary values from there which can be passed to HTTP Request samplers like normal JMeter Variables
Upvotes: 2