cancel
Showing results for 
Search instead for 
Did you mean: 

How to use script assertion that are invovled multiple tags?

Highlighted
Frequent Contributor

How to use script assertion that are invovled multiple tags?

Hi:

Is it possible to use script assertion to verify that for a ModuleCode = "REC_HL_FAMILY", ProfileId (in Configuration tag) != 7?  See below for the partial response.

Thanks,

Li


                  3f1e410b-b73e-4690-a400-a2fa6ad93683
                  REC_HL_FAMILY
                  CPS
                  Family Hot List
                  Noteworthy shows that families can watch together. Recommended programs are suitable for children of various ages, from toddlers to teens.
                  <Configuration><Cobranding PartnerId="0" PartnerName="TV Guide" ImageURL="http://www.tvguide.com/gi/w/81.gif"/><Profiles><Profile ProfileId="0" DisplayOrder="11"/></Profiles></Configuration>
                  false
                  false
                  CPS
                  21
                  2008-02-07T06:30:00Z
                  true
                  255016e2-d757-4375-8e0a-a602889a021c
                  <ContentActions Service="recommendationservice" version="8"><ContentAction Action="get" Method="GetRecommendationItemsInList"><Parameter name="request" type="GetRecommendationItemsInListRQ"><Properties><Property name="RecommendationListId" value="2512F7E7-5A70-47E7-8547-DE0B7C2F575A"/></Properties></Parameter></ContentAction></ContentActions>
             
1 REPLY 1
Highlighted

Re: How to use script assertion that are invovled multiple tags?

Hello!

The easiest way of doing this would be by using XPath assertions, but it is possible to do it in a script assertion as well. Try the following script:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder(messageExchange.responseContentAsXml)

assert holder.getNodeValue("//ns1:ModuleCode") == "REC_HL_FAMILY"
assert holder.getNodeValue("//ns1:ProfileId") != "7"


You may have to change the namespace prefixes, depending on what the rest of your response looks like. You may also want to change the XPath expressions to be more specific, if the response contains multiple DashboardModules or something. Good luck!

Regards,
Dain
eviware.com


 Join the virtual SmartBear Connect user conference on April 27-28! Get your free virtual ticket today!