Kdutta Absent Member.
Absent Member.
1544 views

Xpath based XML checkpoint on an attribute is not working in HP Service Test 11.50

Following X-path based XML Checkpoint is not working in HP Service Test 11.50.


//Books/Book[Category="Computer"]/Items/item[Name="Advanced Programming in C"]/Items/Item[@type="Discount"]/Name

 

I have already selected 'Ignore namespaces' checkbox in XML checkpoints. But the checkpoint is failing and I'm getting the following

 

Couldn't Get Property: OutputEnvelope, with XPath :  //Books/Book[Category="Computer"]/Items/item[Name="Advanced Programming in C"]/Items/Item[@type="Discount"]/Name

 

Xpath checkpoint on attribute is not working in HP Service test. Did anyone experience similar error in HP Service Test 11.50

 

<a:Books>
    <a:Book>
        <a:Category>Computer</a:Category>
            <a:Items>
                  <a:Item i:type="a:Science">
                  <a:Price>8.25</a:Price>
                  <a:Name>Advanced Programming in C</a:Name>
                          <a:Items>
                                 <a:Item i:type="a:Discount">
                                 <a:Price>1.99</a:Price>
                                 <a:Name>5% Special Discount</a:Name>
                                  <a:Items />
                                 <a:ISBN>ABCD123476432</a:ISBN>
                                 </a:Item>
                          </a:Items>
             </a:Item>
         </a:Items>
    </a:Book>

</a:Books>

Labels (1)
Tags (1)
0 Likes
4 Replies
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Xpath based XML checkpoint on an attribute is not working in HP Service Test 11.50

Hi,

It is related with your XPath. The inner Items tag(/Books/Book/Items/Item/Items) seems null.
Can you try this one:

/*[local-name()="Books"]/*[local-name()="Book" and *[local-name()="Category" and text()="Computer"]]/*[local-name()="Items"]/*[local-name()="Item" and *[local-name()="Name" and text()="Advanced Programming in C"]]/*[local-name()="Items"]/*[local-name()="Item" and 'a:Discount'=@*[local-name()="type"]]/*[local-name()="Name"]/text()

0 Likes
Kdutta Absent Member.
Absent Member.

Re: Xpath based XML checkpoint on an attribute is not working in HP Service Test 11.50

@ ntt00015,

 

Thanks for your reply. However, when I tried the Xpath expression that you have suggested, the XML checkpoint failed and I got the following error message in Service test

 

Couldn't Get Property: OutputEnvelope, with XPath:  /*[local-name()="Books"]/*[local-name()="Book" and *[local-name()="Category" and text()="Computer"]]/*[local-name()="Items"]/*[local-name()="Item" and *[local-name()="Name" and text()="Advanced Programming in C"]]/*[local-name()="Items"]/*[local-name()="Item" and 'a:Discount'=@*[local-name()="type"]]/*[local-name()="Name"]/text()

0 Likes
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Xpath based XML checkpoint on an attribute is not working in HP Service Test 11.50

Have you tried the XPath query on a third party application(i.e. XMLPAD) ? And Is 'Ignore namespaces' checkbox in XML checkpoints selected? If it is selected, then deselect. If this is not solve the problem, I 'm sorry, check for alternative solutions (I am not expert at Service Test appl.)
0 Likes
Kdutta Absent Member.
Absent Member.

Re: Xpath based XML checkpoint on an attribute is not working in HP Service Test 11.50

 

 @ ntt00015,

 

   Yes, I have tried the same X path in other tool ( e.g, XPath Builder) and same X path worked there.

   I also tried both selecting the 'Ignore namespace' check box and deselecting the checkbox and runnig the test. It didn't work.

 

   I generally select the 'Ignore Checkbox' in my test so that in the Xpath, I don't have to include the same namespaces as they are in the SOAP response. All the XPath based XML checkpoints work except the one on Atrribute type. So I wanted to know if anyone has tried Xpath based XML checkpoint on an attribute and has any luck ?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.