cancel
Showing results for 
Search instead for 
Did you mean: 

XPathContainsAssertion for CDATA

Frequent Contributor

XPathContainsAssertion for CDATA

Hi,
Is there a way to do an xpath assertion against the contents of a CDATA section that does not require a new Groovy Script for each assertion?
I am looking at creating a subclass of XPathContainsAssertion that will operate on a CDATA section. Is there a better way? How owuld I add my assertion to the required menu's?
Regards
Peter
15 REPLIES 15

Re: XPathContainsAssertion for CDATA

Hi Peter,

have you had a look at http://www.eviware.com/blogs/oleblog/?p=458 ? Maybe that gives you some ideas?

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Frequent Contributor

Re: XPathContainsAssertion for CDATA

Yes, it is helpful.
I would like to make use of the point and click xpath generation capabilities of soapUI pro for this so I am thinking of using a property transfer to transfer the xml in the CDATA section to a mock response and then have a request that gets the response with an xpath match assertion/s on it to check the XML from the CDATA section.

Re: XPathContainsAssertion for CDATA

Hi!

also consider the eventhandler that removes the CDATA, which makes alot of stuff much easier.. but maybe you need the schemacompliance!?

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Frequent Contributor

Re: XPathContainsAssertion for CDATA

Using event handler would be the simplest and most appropriate (seeing as other non-technical testers will need to reuse this solution).

I have got the example event handler working with the target set to the request test step name, which works.
Unfortunately the xml in the CDATA section has right after the bit.<br />The outline view will not work with the xml declaration there and I tried adding it to the string that gets replaced( and escaped the " characters) but it does not seem to match it when I do that&nbsp; <img src='http://community.smartbear.com/legacyfs/online/smilies/huh.gif'>

Re: XPathContainsAssertion for CDATA

Hi!

can you show the entire handler-script for this?

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Frequent Contributor

Re: XPathContainsAssertion for CDATA

if(submit.response == null)
        return
def content = submit.response.responseContent
content = content.replaceAll("", "")

log.info(content)
submit.response.responseContent = content

Re: XPathContainsAssertion for CDATA

Hi!

You'll need to escape the dot I think, does

...
content = content.replaceAll("", "")
...

work better?

regards!

/Ole
eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Frequent Contributor

Re: XPathContainsAssertion for CDATA

Got it working!
Had to use \\ in front of ?

Now.....
how do I specify a regex in the  target of the event handler so that we can use naming convention for test cases that needs this treatment?
I've tried *REMOVE_CDATA* but I get an error message about Dangling meta character '*' near index 0
Frequent Contributor

Re: XPathContainsAssertion for CDATA

figured it out:
Using
.*REMOVE_CDATA.*

Thanks
New Here?
Join us and watch the welcome video:
Announcements