Closed schkolne closed 3 years ago
for those who care, i ended up solving this using RF's json library like so
Purchase exists with name
[Arguments] ${name}
Set Headers { "authorization": "Bearer ${authtoken}"}
GET /purchases
${purchases} = Output response body /dev/null
${values}= Get Value From Json ${purchases} $..name
List Should Contain Value ${values} ${name}
make sure to add Library JSONLibrary
at top of file
Hi @schkolne
For Output
the only option is redirect it to /dev/null
.
For your issue, I think it could be solved by using String
keyword. It accepts JSONpath as the first parameter and you can add a validation to it as well.
E.g
Purchase exists with name
[Arguments] ${name}
Set Headers { "authorization": "Bearer ${authtoken}"}
GET /purchases
String $..name ${name}
Hi - new to RF and loving RESTinstance thanks so much for writing it!
I want to write a test to see if any of my purchases have a certain name. I can successfully test the to see if 0th instance matches...
... but scratching my head as to how to generalize this to check all N purchases to see if any match. I know this must be simple but after quite a bit of fiddling I can't make it happen. Anyone know the answer?
[while we're at it -- you'll notice some grossness in my sample... I ended up making my Output go to /dev/null to store a variable without printing it to the output... is that really the best way, feels like I'm missing something]