How to automatically loop multiple Ids in Jmeter - variables

I am now trying to use Jmeter.
I have created a http request to receive multiple Ids from one response and used Json extractor to store the Ids.
The stored Ids are like:
id_1:1234
id_2:2234
id_3:3234
id_ALL:1234,2234,3234
Now, I would like to use those Ids in another response, but I don't want to configure the variable every time because there are numbers of id_{ascending number}.
example:
url: http://localhost/{id_1}
method: GET
url: http://localhost/{id_2}
method: GET
url: http://localhost/{id_3}
method: GET
I have tried to use User defined variable like: ${id_${counter}}, but it didn't work. How do I get this operation successfully?
Thanks very much.

The easiest is using ForEach Controller configured like:
once done in the ForEach Controller's child(ren) you will be able to refer the "current" id as ${id}
If you want to use the current iteration counter you need to wrap everything into __V() function like:
String representation just in case:
${__V(id_${__intSum(${__jm__Loop Controller__idx},1,)},)}
More information: Here’s What to Do to Combine Multiple JMeter Variables

Related

How to stop a test after finding specific word in jmeter response?

How can we stop a jmeter test after finding a specific word from json response:
{"code":12345,"data":{"mylist":[{"myid":111,"secId":2,"TypeId":1,"name":"one two three" ,"description":"thats the value"}]}
Put your request under the While Controller
Use the following __jexl3() function as the condition:
${__jexl3("${value}" != "thats the value",)}
Add JSON Extractor as the child of the request and configure it as follows:
Names of created variables: value
JSON Path Expressions: $.data.mylist[0].description
That's it, the While Controller will loop until "description" fields becomes thats the value
Demo:

I want to pass the header value in methods

Scenario : I need to verify the logs response on server on the basis of Tracking-Id.
I had passed the tracking-id using 'header.js' file, here i define metod which get the unique UUID for every request and passed in header.
Now I need that header value to passed in some method to get logs only for specific Tracking-Id
Is there any way to achieve this in karate?
Yes, you can use karate.set('someVarName', uuidValue) in JS and then back in the feature you will be able to: * print someVarName.
EDIT: please see this commit for an example: link

Dojo dStore Rest dGrid sort parameter

When I fetch from a dStore the URL looks something like this
http://localhost/rest/dojo?department=sales
which works fine. If I then click in the header of the dGrid the sent URL looks like this.
http://localhost/rest/dojo?department=sales&sort(+id)&limit(25)
Shouldn't it send &sort=+id&limit=25? I am using Java and Spring for the backend and it expects the parameters to be formatted this way. Right now I can not receive the extra parameters. Is there a way to get it to send the parameters the way Spring is expecting them?
sort(...) and limit(...) are the default behaviors of dstore/Request (which Rest extends), but these can be customized via sortParam for sort, and useRangeHeaders or rangeStartParam and rangeCountParam for range.
For example, to result in &sort=+id&limit=25 as you requested, you could set up your store as follows:
var store = new Rest({
target: '...',
sortParam: 'sort',
rangeStartParam: 'offset',
rangeCountParam: 'limit'
});
I've additionally assumed above that offset is the GET parameter you'd want to use to indicate what record to start at when requesting ranges. Generally if you're not using range headers (useRangeHeaders defaults to false) and you want to set a count GET parameter, you'll also need to set a start GET parameter.
These properties are listed in the Request Store documentation.

Ushahidi GET request with multiple parameters

I'm working on an application that uses Ushahidi to return an array of JSON objects using a HTTP GET request. I would like to use two parameters in the request. These parameters are category id and max id. In the URL below the first parameter is &by=catid&id=2 and the second is &by=maxid&id=499. The example below will only read the last parameter entered. So the catid parameter would be ignored.
http://fixyourstreet.ie/api?task=incidents&by=catid&id=2&by=maxid&id=499
Why will this request only return JSON objects by the last parameter entered rather than both parameters?
Any help would be much appreciated.
Those requests typically get parsed as key-value dictionaries by web servers.
This means the "by" parameter can only have one value when your request is processed and responded to. You will have to make 2 subsequent requests if you need all these values :
http://fixyourstreet.ie/api?task=incidents&by=catid&id=2
http://fixyourstreet.ie/api?task=incidents&by=maxid&id=499

How to enable dojox.data.JsonRestStore access struts2's action to retrieve data? I mean how to configure 'target' or others

I tend to use dojox.data.JsonRestStore as my grid's store, but I am always failed to access struts2 action, I am unfamiliar in REST, is it only can be used in servlet rather than struts2, etc.
Currently, My project is using struts2 + spring as backend skill and dojo as front-side skill, have you any ways for me to make dojox.data.JsonRestStore access a structs2 action class?
Thanks in advance.
to get the data, all you need is an HTTP GET that returns an array of JSON objects. The return value from the action must be a string with something like:
[
{
"penUser":"Micha Roon",
"submitTime":"12.03 13:20",
"state":"Eingang",
"FormNumber":"001001"
},
{
"penUser":"Micha Roon",
"submitTime":"12.03 13:20",
"state":"Eingang",
"FormNumber":"001001"
}
]
If you want to be able to update objects you have to have a method that reacts to PUT with the same URL as the one you used for GET and if you need to delete, DELETE will be used. The important part is that it must be the same URL.
In order to have JsonRestStore pass the ID in a GET parameter instead of appending it to the URL, you could specify the URL like so:
target:"services/jsonrest/formstore?formId="
When you call yourStore.get("123") the request will try to get http://yourserver:port/AppContext/services/jsonrest/formstore?formId=123
REST is nothing more than a convention.
You can use a RESTFull API like jersey.java.net in order to make your life easier and your URL more RESTFull.