XML Assertor - String Comparison

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
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
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    We are getting the same types of errors but we are working with integer instead of boolean. We've even tried casting by wrapping using the number() XPath function but we still get the same error. I'm just adding this comment to point out that there are other experiencing this issue.
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hello this is Baxter Campbell with Parasoft Support.

    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
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    edited December 2016

    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
Sign In or Register to comment.