Contributions
- 8 years agoPlace ReadyAPI QuestionsReadyAPI Questions564Views0likes0Comments
I need to be able to put a Range into my JSON Assertions
I need to be able to put a Range into my JSON Assertions JSONPath Expression $.searchResult.products Expected Result ${SBS DataSource#count} If I try - ${SBS DataSource#countLowerRange} <= $.searchResult.products is true it throws the following error - Assertion failed. Path [${SBS DataSource#count} = $.searchResult.products]:AssertionException:Assertion failed. Path [${SBS DataSource#count} = S.searchResult.products]: ClassCastException:java.lang.String cannot be cast to net.sf.json.JSON. Thanks, Laura8 years agoPlace ReadyAPI QuestionsReadyAPI Questions606Views0likes1CommentRe: I need to be able to put a Range into my Assertions
This solution worked for the Web Services version of the call but now moving to the JSON version, the same method isn't quite the same. JSONPath Expression $.searchResult.products Expected Result ${SBS DataSource#count} If I try - ${SBS DataSource#countLowerRange} <=$.searchResult.products is true it throws the following error - Assertion failed. Path [${SBS DataSource#count} = $.searchResult.products]:AssertionException:Assertion failed. Path [${SBS DataSource#count} = S.searchResult.products]: ClassCastException:java.lang.String cannot be cast to net.sf.json.JSON. Is there a way to do it in the JSON as well? Thanks, Laura8 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.6KViews0likes1CommentRe: I need to be able to put a Range into my Assertions
That got me close enough. Here is what I did. Two assertions: Lower End of the Range: XPath Expression: declare namespace ns1='http://ws.ussco.com/eCatalog/catalog/1'; ${DataSource RedPen SmallBS#totalResultsLowerRange} <= //ns1:getSearchResponse[1]/ns1:searchResponse[1]/ns1:ItemPage[1]/ns1:TotalResults[1] Expected Result: true Upper End of the Range: declare namespace ns1='http://ws.ussco.com/eCatalog/catalog/1'; ${DataSource RedPen SmallBS#totalResultsUpperRange} >= //ns1:getSearchResponse[1]/ns1:searchResponse[1]/ns1:ItemPage[1]/ns1:TotalResults[1] Expected Result: true And then all the Requests in my data set don't have to match exactly. Thanks for giving me both methods! Laura8 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes2CommentsRe: I need to be able to put a Range into my Assertions
Thanks for the quick reply. I have tried the script and it does work with my Requests. A follow up question. In my automation project, I am using a Data Driven Approach whenever possible. A Script Assertion doesn't seem to be able to call back to the Data Source for the script (use the string${DataSource RedPen SmallBS#totalResults} to go to a Grid to pick up the Groovy Script you created, although it works if I put that script directly into the Groovy Script Assertion.) So does this mean I can either use a Range Groovy Script Assertion for Request that will come back within a similar Range or use a Data Source for Exact TotalResults to store for Assertions, but I would not be able to use a Data Source to store a Groovy Script for a Range of TotalResults? (Let me know if that question doesn't make sense.) Laura8 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes0CommentsI need to be able to put a Range into my Assertions
In order to be able to change Environments easily, I need to be able to put a Range into my Assertions for a TotalResultsfield. I have found references on the board to the ability to do this but I can't get the syntax quite right and there doesn't seem to be an example for exactly what I need. Here is the tag for the aggregate I am targeting: <ItemPage> <FirstResult>1</FirstResult> <ResultsReturned>19</ResultsReturned> <TotalResults>190</TotalResults> <Items> Here is the Assertion I currently have without a Range: XPath Expression - declare namespace ns1='http://ws.ussco.com/eCatalog/catalog/1'; //ns1:getSearchResponse[1]/ns1:searchResponse[1]/ns1:ItemPage[1]/ns1:TotalResults[1]/text() Expected Result - ${DataSource RedPen SmallBS#totalResults} DataSource RedPen SmallBS#totalResults 190 What I would like to see is a + or - tolerance of 5%. I have tried things like two Assertions ">= 181" and "<=200", or "greater than or equal to 181" and "less than or equal to 200". I have tried one Assertion "Between 181 and 200", and so on. Can someone help me with the exact syntax? Thanks, Laura Endpoint: https://ws.ussco.com/eCatalog/catalog/001/syncSolved8 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.7KViews0likes6CommentsIs there a widget to check whether a tag is NOT there in the JSON?
I am attempting to use Data Driven testing with JSON calls and in cases where the Response will only contain a tag in certain circumstances, I can't put it into a general loop unless I can do a false on an Assert when I am checking whether a tag exists. When I try it currently, I always get an error that the tag is not found or something to that effect.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions637Views0likes0Comments