armygrad
1 year agoContributor
Boolean check
Hi All I'm almost there, i need to check that a json response contains 1234 within an array, and return true. and if it doesn't return false. boolean check = "FAIL"
if (response.contains("1234") ...
What i need to do is compare the value of Field 1 to what is in Datasourcebook1, then if both are the same then return true, but if DatasourceBook1 is different return false.
It is difficult to imagine the use case you are working on and answer as desired unless it is mentioned in the question.
I am sure you will be able to retrieve the value from the source you mentioned and compare it instead of static value(which i gave because it was mentioned in the response.
Hi,
The use case is from a previous question...
https://community.smartbear.com/discussions/readyapi-questions/assertions/262648/Assertions | SmartBear Community
In ArmyGrads Groovy snippet, the assertion isn't required for the use case. But I can see why Rao added it for his demo to show that the value can be found.
For ArmyGrads example to work, you need use Get Data to pull in the required value from the datasource step and assign it the var datasourceBook1 prior to the IF statement.
Something like...
def datasourceBook1 = context.expand( '${CustomerDataSource#Book1}' );
Then you should both the response value and datasource values.