Unable to extract jsonpath in jmeter - jmeter

I am using jsonpath.com to evaluate my jsonpath expression.
$.[?(#.ContractId=='ДГМ-313349')].[*].ContactPerson[0].[*].Email
So I successfully evaluate my jsonpath on this page (see: https://snag.gy/LqSEy0.jpg) and get string what I need.
But when I insert my jsonpath expression in Jmeter to JSON path assertion and run test - it fails. Jsonpath assertion always finds empty string. I am using plugin from JP#GC. Is any difference between syntaxes of these json extractors? I also used JSON Path extractor and extract json from variable. The result is the same.

I have solved problem. There was a dot missing after "$":
$..[?(#.ContractId=='ДГМ-313349')].[*].ContactPerson[0].[*].Email

Related

I Want extract value from json response using Regular Expression Extractor

In Jmeter, run one API and get the below response. I want to extract File_Name & ReqId value from the below response using Regular Expression Extractor using only one "Regular Expression Extractor" . and pass these two values to another API, so how do that?
{"FileCode":["Aadhar"],"File_Name":"271954143_1_1.jpg","Aadhar_Features":[{"Confidence":"79.46","File_Code":"UIA","Count":1},{"Confidence":"87.87","File_Code":"GOI","Count":1},{"Confidence":"88.25","File_Code":"Aadhar_Slogan","Count":1},{"Confidence":"92.36","File_Code":"SatyamevaJayateLogo","Count":1},{"Confidence":"92.99","File_Code":"AadharLogo","Count":1},{"Confidence":"97.01","File_Code":"Aadhar","Count":2}],"ReqId":"REQ_1639032634869","Classes":[{"Confidence":[96.21741771697998,98.64940047264099],"Coordinates":["383,269,110.0,27","375,882,105.33333333333333,28"],"Count":2,"Name":"AadharNo"}]}
Here some wise man suggested using JSON JMESPath Extractor as it's faster, easier and more reliable.
If despite this you prefer using Regular Expression Extractor - here is the regular expression for the File_Name:
"File_Name"\s*:\s*"(.+?)"
and here is the one for the ReqId
Example Regular Expression Extractor configuration:
Example JMeter Variable usage:
More information:
Apache JMeter: Regular Expressions
Using RegEx (Regular Expression Extractor) with JMeter

How to get the value of a data-amount JMeter

How to get the value of a data-amount JMeter
I tried to get the value using a xpath extractor. But I always got an empty string. What am I doing wrong?
//*[#class = 'panel-body']//*[#class='fade-in'][1]/#data-amount
There is a couple of problems with your XPath expression, for instance:
//*[#class = 'panel-body']//*[#class='fade-in'][1]/#data-amount
^ - extra slash ^ - not required
I also don't like * wildcard, however it might be a weird form of your test scenario so let it be.
Being converted to "normal" XPath expression it should look something like:
//*[#class='panel-body']/*/#data-amount
Demo:
It may be simplified to something like:
//div[#data-action='bid_online']/#data-amount
References:
XPath Language Specification
Using the XPath Extractor in JMeter
XPath Tutorial

Fetching number from JSON response in JMeter

I am new to JMeter, I want to fetch the 123 number from the below JSON response and store it in a variable. And user the value for further requests.
{"data":" Abcd efgh 123 successfully created","error":null,"info":null,"warn":null}
Can someone address to achieve it using BeanShell Postprocessor and Regular Expression Extractor or if any there is any other way to achieve the same.
Add Regular Expression Extractor Post-Processor as a child of the request which returns above JSON
Configure it as follows:
Reference Name: anything meaningful, i.e. number
Regular Expression: (\d+) successfully created
Template: $1$
You will be able to refer the extracted value as ${number} or ${__V(number)} later on where required.
References:
JMeter Regular Expressions
Perl 5 Regex Cheat sheet
Using RegEx (Regular Expression Extractor) with JMeter
Also be aware that JMeter 3.0+ comes with JSON Extractor, it is not applicable for your current enquiry however if later on you will need to get the whole attribute value(s) it will be much easier to use it rather than regular expressions
Regular Expression Extractor with (\d+) is the simpliest.
Reference Name: myNumber
Regular Expression: (\d+)
Template `$1$`
Match No. `1`.
It will be saved in myNumber variable

What template needs to be added in regular expression post processor in Jmeter for the following condition

Regular Expression -"p_instance" value="(.*?)"
Match count: 1
Match[1][0]="p_instance" value="11917272245034"
Match[1][1]=11917272245034
When added $1$ in template - error is displayed(request is not created)
$1$$1$ is dding duplicate strings in the request.
What should be the template to fetch this value
Just add a Debug Sampler to your Test Plan - this way you will be able to see all the variables generated by the Regular Expression Extractor in the View Results Tree listener. See How to Debug your Apache JMeter Script article for more details.
Going forward when asking for a help with the regular expressions include essential part of the response and indicate which value you are looking for.
Here comes mandatory advice not to use regular expressions for parsing HTML and suggestion to use CSS/JQuery Extractor or XPath Extractor instead.

Not able to read session id from response in jmeter

i want to fetch "chat_session_id": 8216, from response data and apply regular expression extractor
"chat_session_id": (.+?)
but it only fetches 8 instead of 8216
You did correctly, the mistake is you need to add comma to your regular expression
Actual value: "chat_session_id": 8216,
Regx: "chat_session_id": (.+?),
Try amending your regular expression to look like:
"chat_session_id": (\d+)
This one will match any number following the chat_session_id: so it should work as it evidenced by View Results Tree listener output:
In general, given you are getting the response in JSON format it would make more sense to use JSON Extractor which is designed for working with JSON data type. The relevant JSON Path Expression would be as simple as:
$..chat_session_id

Resources