You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Jean-Sebastien Vachon <va...@gmail.com> on 2016/12/15 14:26:31 UTC
Using localStorage in JMeter
Hi All,
I am trying to build a test suite to test the performance of one of our
system and I need to provide some information to each thread so that the
following code will work...
<script type="application/javascript">
var getName = function() {
var name;
try {
name = window.localStorage.getItem("user-name");
} catch(error) {
console.log(error);
}
if(!name) {
name = window.prompt("What's your name, please ?", "Rachel
Smith");
...
I tried setting a cookie using the CookieManager but I can not get it to
pass a predefined value.
Is there a way to put something in the localStorage so that the javascript
code will see it and proceed?
Thanks
Re: Using localStorage in JMeter
Posted by UBIK LOAD PACK Support <su...@ubikloadpack.com>.
Hello,
JMeter is not a browser, so it does not interpret Javascript.
It works on protocol level. You javascript here will end up sending a
request to the server, that's where the information will be available.
If you need to provide this to the request then you will use a CSV Data Set
(and a CSV file containing the names) and variables to send it:
- http://jmeter.apache.org/usermanual/functions.html#functions
-
http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config
If you need to extract it from a response, you will use Extractors (CSS/
JQuery extractor, JSON-Path, XPath or regex):
-
http://jmeter.apache.org/usermanual/component_reference.html#postprocessors
Another option if you don't have much load to inject is to use WebDriver
and a plugin for it from jmeter-plugins.org
Regards
@ubikloadpack
On Thu, Dec 15, 2016 at 3:26 PM, Jean-Sebastien Vachon <va...@gmail.com>
wrote:
> Hi All,
>
> I am trying to build a test suite to test the performance of one of our
> system and I need to provide some information to each thread so that the
> following code will work...
>
> <script type="application/javascript">
> var getName = function() {
> var name;
> try {
> name = window.localStorage.getItem("user-name");
> } catch(error) {
> console.log(error);
> }
> if(!name) {
> name = window.prompt("What's your name, please ?", "Rachel
> Smith");
> ...
>
>
> I tried setting a cookie using the CookieManager but I can not get it to
> pass a predefined value.
>
> Is there a way to put something in the localStorage so that the javascript
> code will see it and proceed?
>
> Thanks
>