cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare response with excel data using regular expression

Highlighted
Occasional Visitor

How to compare response with excel data using regular expression

Hi all,

I am comparing entire response with data in excel using groovy script assertion now there is change in the response; there are tag values which are dynamic. How to compare values in response with excel data by using regular expression?

 

 

 

Thanks,

Deepak

2 REPLIES 2
Highlighted
Community Hero

Re: How to compare response with excel data using regular expression

May be you want to provide sample data where you got the trouble doing it?


Regards,
Rao.
Highlighted

Re: How to compare response with excel data using regular expression

I take it that you want to write the assertion in Groovy code?

 

If so, it's very easy to use regular expressions in Groovy. Assuming you have the value in the variable responseValue, the following expression will return true if and only if the value matches the regex [A-Z]+

 

responseValue ==~ /[A-Z]+/

 

Removing one character from the expression will give you a java.util.regex.Matcher object instead:

 

responseValue =~ /[A-Z]+/

 

 

The Matcher object is very useful for finding out more about the match, so you may want to read up on what you can do with it: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html.

 

Regards,

Manne, Ready! API Developer

 

 

 

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite
Top Kudoed Authors