I need to extract a request number from "response data" - jmeter

I am trying to use Regular expression extractor to extract, but i don't know how to use it here. Since the "request number" is visible only in "Response Data" of "View result tree". where should i place the post processor. what would be my regular expression.
edit: I have added my regular expression and result screen

Your response value is a number, without double quotes, so change your Regular expression to
"response":(\d+)

Parsing JSON data using regular expressions is not the best idea, I believe you should be using JSON Extractor instead.
It's available since JMeter version 3.0 and you should be able to use it instead of the Regular Expression Extractor.
The relevant JsonPath query will be as simple as:
$.response
Full configuration just in case:
Also be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider migrating to JMeter 5.0 (or whatever is the latest version available at JMeter Downloads page) on next available opportunity.

Related

How to handle escape characters (backslash) in jmeter

while executing the API's using jmeter tool in the response i get some value as '1K\/vyEh'.
while storing this value in the variable it is observed that the backslash does not get stored in the variable resulting in saving the value as '1K/vyEh'
I need guidance of how to save the value as is in the variable
There are too many "unknowns" in your question so unfortunately it is not possible to provide a comprehensive answer without seeing:
at least partial (better full) response
and the way you're storing the value into a JMeter Variable
Here is a quick demo that in theory it is possible:
The demo assumes:
Dummy Sampler
JSR223 PostProcessor
Groovy language and regular expressions

Jmeter JSONs comparison

Currently I am working on moving some API DDT (data from CSV) tests from RobotFramework to Jmeter and what troubles me is the lack of proper JSONs assertion which is able to ignore some keys during comparison. I am totally new to jmeter so I am not sure if there's no such option available.
I am pretty sure we are using the wrong tool for this job, especially because functional testers would take the job of writing new tests. However, my approach (to make it as easy as possible for functionals) is to create jmeter plugin which takes response and compare it to baseline (excluding ignored keys defined in its GUI). What do you think? Is there any builtin I can use instead? Or do you know anything about some existing plugin?
Thanks in advance
The "proper" assertion is JSON Assertion available since JMeter 4.0
You can use arbitrary JSON Path queries to filter response according to your expected result
Example:
If it is not enough - you can always go for JSR223 Assertion, Groovy language has built-in JSON support so it will be way more flexible than any existing or future plugin.
Please find below the approach that I can think of:-
Take the response/HTML/json source code dump for the base line using "save response to a file".
Take the response dump for the AUT that needs to be compare or simply 2nd run dump.
Use 2 FTP sampler's to make calls for the locally saved response dump's.
Use compare assertion to compare the 2 FTP call response's. In the compare assertion, you can use RegEx String and Substitution to mask the timestamps or userID to something common for both so that it will be ignored in comparison.
Below I have shown just an image for my thought's for help.
You need to take care on how to save and fetch the response's.
Hope this help.

how to check that tag does not contain spaces or null as value using regular expression

I am trying to validate a string (containg numbers, alphabets and spaces in between words and also contains trailing and leading white spaces) .I need a regular expression which i can put in response assertion of jmeter
Standard recommendation not to use regular expressions for working with HTML and/or XML.
Go for XPath Assertion instead, using it you can implement your requirement using XPath query like:
//yourElement[#yourTag!='null' and not(contains(#yourTag,' '))]
XPath language is quite easy, at least it is much easier to create and read XPath expressions rather than "regular" ones. Check out XPath Tutorial to get started and How to Use JMeter Assertions in Three Easy Steps guide to learn more about assertions available in JMeter.

JMeter: How to ignore dynamic parameters in response assertions

I have to ignore dynamic property value while cmpmarison. Can you please suggest how to do so.
Currently I have used as
(\d+)
And Pattern matching Rule as "Contains"
Can anyone please help on same
regards
Vishal
Given your current setup, if the response will contain any number - your assertion will pass, otherwise it will fail. You can use Perl5-style regular expressions to handle dynamic response parts and static strings for doing the checks. See How to Use JMeter Assertions in Three Easy Steps article for more information.
The other approach is extracting the dynamic parts using Regular Expression Extractor, converting them into JMeter Variables and using these variables in the Response Assertion. Regular Expression Extractor is executed before the assertion so this way you will be able to work it around in a more "transparent" way.

Jmeter regex failing

How do I get the text "Need to grab this" using Jmeter - Regex
"suggestionsIdentifiers":[{"#v":"some other variable","#t":"string"}],"saveInto":["need to grab this"],"labelPosition":"ADJACENT","#t":"PickerField"}]}]}
It isn't very recommended to use Regular Expressions to work with JSON entities as they're quite complex, multiline, you need to escape a lot of characters, etc. so regular expressions are hard to develop and quite fragile.
I would recommend switching to JSON Path Extractor available via JMeter Plugins, it works with JSON like a charm.
JSON Path expression would be something like:
$..saveInto[0]
N.B. your response is not full, it doesn't look like a valid JSON so if you have any problems - please update your question with the full response so we could suggest an appropriate JSON Path
See Using the XPath Extractor in JMeter (Scroll down to "Parsing JSON") for plugin installation instructions and some form of JSONPath language reference.

Resources