AnsweredAssumed Answered

When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although the

Question asked by saumya_Pandey168 on Jun 18, 2018
Latest reply on Jul 10, 2018 by saumya_Pandey168

I am using scripted assertion for validating JSON response tag values with JDBC SQL result column values but when particular JSON tag is not found (as the tag is option tags in service response) the value in the created property e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although the SQL result is empty. can anyone suggest a way to fix this issue?

 

I am using JSON filter to extract tag value and below beanshell code snippet to assert.

var result=false;
String result1;

//DOB validation
if(testExec.getStateValue("Res_DOB").equals("") && testExec.getStateValue("DB_DOB").equals(""))
{
result=true;
testExec.setStateValue("result1", result);
}

else if
(testExec.getStateValue("Res_DOB").equals(testExec.getStateValue("DB_DOB")))
{
result=true;
testExec.setStateValue("result1", result);
}
else
{
testExec.setStateValue("result1", "False");
}

 

I tried to use contains, includes functions to compare partial string, but beanshell does not support this it seems.

Suggest me the solutions ASAP.

 

Thanks,

Saumya Pandey

Outcomes