XML Assertor - String Comparison
Hi,
I want to test saving data and then verify that the saved data is returned in the xml reponse from a REST service call. The response xml looks something like this (except there is much more data than presented here):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<DataDictionary>
<complexType state="3" uid="341" isValid="true" modified="false" major="1" minor="0" description="SOATest Description" name="soaTestDataType_79" type="soaTestDataType_79">
<attribute isValid="true" modified="false" major="1" minor="0" description="" name="AccountNumber" type="AccountNumber" baseType="int" abstractType="simple"/>
</complexType>
</DataDictionary>
<status code="success" message="success"/>
</response>
So, what I'd like to be able to do is verify that "name="soaTestDataType_79" is returned in the response since that is the data type I saved beforehand.
I tried to do this using a String Comparison Assertion, searching on "Selected Element": /response/DataDictionary/complexType/@name="${name}" (where name is a variable holding the name of the saved data type). It is configured for "expected value" equals "true".
However, I get the following error when I run the test:
An error occurred while processing an assertion: Can not convert #BOOLEAN to a NodeList!
Is there a way to do this verification using String Comparison Assertion?
Thanks
I want to test saving data and then verify that the saved data is returned in the xml reponse from a REST service call. The response xml looks something like this (except there is much more data than presented here):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<DataDictionary>
<complexType state="3" uid="341" isValid="true" modified="false" major="1" minor="0" description="SOATest Description" name="soaTestDataType_79" type="soaTestDataType_79">
<attribute isValid="true" modified="false" major="1" minor="0" description="" name="AccountNumber" type="AccountNumber" baseType="int" abstractType="simple"/>
</complexType>
</DataDictionary>
<status code="success" message="success"/>
</response>
So, what I'd like to be able to do is verify that "name="soaTestDataType_79" is returned in the response since that is the data type I saved beforehand.
I tried to do this using a String Comparison Assertion, searching on "Selected Element": /response/DataDictionary/complexType/@name="${name}" (where name is a variable holding the name of the saved data type). It is configured for "expected value" equals "true".
However, I get the following error when I run the test:
An error occurred while processing an assertion: Can not convert #BOOLEAN to a NodeList!
Is there a way to do this verification using String Comparison Assertion?
Thanks
0
Comments
Your current set up is not working, because the result from a XPath Evaluation needs to be a Node or collection of Nodes. It cannot be a boolean, or a number.
If you are expecting a result to be exactly the same as something you have stored, you can use the Value Assertion, and provide an Xpath to that attribute. Then, outside the XPath Evaluation, you can selected a parametrized value to compare it to, ("name" in your example), and that should check what you are looking for.
If you need any help setting this up, or for any reason this does not work for you, feel free to post a response.
-Baxter Campbell
Hi Baxter,
I realized my mistake after posting this question, as you pointed out the XPath evaluation was a boolean and needed to be a node. I changed my XPath as follows:
/*/*/complexType[@name="soaTestDataType_79"]/@uid
and it worked as expected.
Thanks,
Stephen