Forum Discussion

willtestforfood's avatar
willtestforfood
Occasional Contributor
13 years ago

${#project#endpoint} does not work in script assertion

Using Script Assertion.. how come this code works:

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["ns1"] = "http://www.example.com/examplepage.htm"
def node = ( holder["//ns1:Response[1]/ns1:RESPONSE[1]"] )

assert node != null



...but this does not?

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["ns1"] = '${#Project#endpoint}/examplepage.htm'
def node = ( holder["//ns1:Response[1]/ns1:RESPONSE[1]"] )

assert node != null


Everywhere else (so far) I am able to use '${#Project#endpoint} without a problem. The second example above returns null. Thanks!

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    in a script you need to wrap this with context.expand, ie

    holder.namespaces["ns1"] = context.expand( '${#Project#endpoint}/examplepage.htm' )

    Does that help?

    regards!

    /Ole
    SmartBear Software