is it possible for selenium to validate XML elements based on Xpath

my webpage generates an XML in the below format, can we able validate the text for particular XPath using selenium like if I want to get cost using XPath: productListing[@title=" ABC Products"]/product[1]/cost. how to write that in selenium

<span id="_0:preferredLocaleTipTextLbl0"><note>   <?xml version="1.0"?>   <productListing title="ABC Products">    <product>      <name>Product One</name>      <description>Product One is an exciting new widget that will        simplify your life.</description>      <cost>$19.95</cost>      <shipping>$2.95</shipping>    </product>    <product>      <name>Product Two</name>      ...    </product>    <product>      <name>Product Three</name>      <description>This is such a terrific widget that you will        most certainly want to buy one for your home and another one        for your office!</p>      <cost>$24.95</cost>      <shipping>$0.00</shipping>    </product> 

Add Comment
1 Answer(s)

Selenium does not native support verifying text present in an XML page. Why not check with language which you’re writing automation script? If you’re doing automation with Java, you can use Java XPath Parser

Answered on July 17, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.