Jmeter :- ArrayList Handling in Parameters tab - arraylist

Case: Select 100 records and mark them verified.
Steps:
Getting 25-100 records based on IDs via JSON extractor.
Posting verified on 25-100 records selected.
Actual Result: (Getting 500 Error)
Expected Result: (How it is working in application)
How can I handle the above case?

Your format is not correct, you need to send the data like:
The request body can be generated dynamically using JSR223 PreProcessor and some Groovy scripting, check out HTTPSamplerBase.addArgument() function for more details.

Related

Retry until with dynamic path or params [duplicate]

I have a use-case where I need to first call an API to get a list of ID's. From this response a random ID is chosen. Next I call a 2nd API which uses the random ID as a component in the path.
It's possible the 2nd API call can return an empty response, therefore I want to utilize retry until but use a different random ID in the path per retry iteration.
I've tried a couple of things:
First "in-lining" the JS function in the path to get a random ID:
Given path firstPart, myGetRandomId(idList), lastPart
And retry until response.length > 1
Second, tried putting the JS function in a Examples: as part of a Scenario Outline:
Given path firstPart, <ID>, lastPart
And retry until response.length > 1
Examples:
| ID |
| myGetRandomId(idList) |
The general issue I can't figure out is how to get the JS function to evaluate in either of this "in-line" kind of approaches.
And ideas/suggestions appreciated.
The way that the Karate retry until works is that it will re-play the request as-is and you can't modify it.
So you have to take a different approach. Use a JS loop. Look at this example in the demos:
https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/polling/polling.feature

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

JMeter: Passing Key Value Pairs Not Working

I'm using JMeters to automate API testing to/from our database using basic CRUD methodology. After the record creation, I'm trying to perform 3 different types of Reads (think CRRRUD). :)
Read 1 - Retrieve by ID
HTTP (GET) the base URL is appended with the saved record ID.
http..../crud/tableName/${newRecordId}
This returns
Read 2 - Retrieve by field type with no defined value
HTTP (POST) the base URL is extended with a "search" as the end. A Key is defined ("name") with no value.
http..../crud/tableName/search
Parameter Name = name
Value = {undefined}
This returns all records within the table whose field ("name") is not null.
Read 3 - Retrieve by field type with a defined value
HTTP (POST) the base URL is extended with a "search" as the end. A Key is defined ("name") with the value generated during the creation request.
http..../crud/tableName/search
Parameter Name = name
Value = Metropolis
This, too, returns ALL of the records within the table instead of just the record(s) whose name = Metropolis.
This 3rd Retrieve works properly when using a REST client, (e.g., Postman, Advanced REST Client, etc.) when defining the Key|Value pair as "name|Metropolis". So it must be something within JMeter that I'm missing.
Any insight is appreciated!
There is only one correct answer: compare what's being sent by REST Client and JMeter using sniffer tool (i.e. Wireshark), detect the differences and configure JMeter accordingly.
Just a guess: given you mentioned "API" an "REST" words maybe you need to pass it as JSON like:
{"name":"Metropolis"}
as a single parameter value
or in formatted way (in case if server checks Content-Length and/or wants the request to be properly formatted)
You may also need to add HTTP Header Manager in order to send Content-Type header with the value of application/json. See Testing SOAP/REST Web Services Using JMeter guide for more details.

How to use Xpath extractor to extract mutiple fields using SOAP request in Jmeter?

I imported the webservice and did my first transaction passed. I see the request and reply xml
Now I want to extract ton of field values from the reply xml that I got and need to pass into Request xml.
For one field I know how to do that. I use Xpath Extractor to extract like this
//*[local-name()='Data']/text()`.
In the next action, I can just use as ${Data} which is working fine.
But I need to extract the text content from ton of fields that need to be passed into the next action.
How to do that using Xpath Extractor?
If your XPath query matches multiple /Data/text fields they will be caught as
TEXT_1=first match
TEXT_2=second match
etc.
If you need to combine results from different queries it can be done via pipe sign - | like
//*[local-name()='Data']/text()` | //*[local-name()='Something else']/text()
In this case result will go to the single variable.
Third option is using as many XPath extractors as needed.
See XPath Tutorial for general language reference and Using the XPath Extractor in JMeter guide for more tips and tricks.

where to see xPath Extractor results in Jmeter

I am new to Jmeter, I want to see the Xpath Extractor generated results.
I have
Reference Name : pt_idx
Xpath query : //patientList/patient/idnetifierList/identifier/text()
Default Value : 0
Please clarify my doubts, can i use Xpath query generated results in Http Request?
Is those result will store in pt_idx variable?
Finally, where can i see the results?
Yes, you can use it in an Http Request, I have previously used several XPath Extractors and been able to use them as variables in subsequent http request using the placeholder notation ${varname} (for you it would be ${pt_idx})
To verify the value of the variable, I could do it via the report by looking at the HTTP Request (as I used the variable to fill a request parameter).
Hope it helps.
Finally, where can i see the results?
Add a Debug sampler by going to the thread group and right clicking Thread group -> add -> sampler -> debug sampler. The debug sampler will give the values that the XPath Extractor retrieves. Simple add a View Results Tree and select the debug sampler and view the Response data tab and the info should be all there.