1. Property Expansion:
1> Property Expansion in soapUI: ${Search Request#Response#//ns1:Item[1]/n1:Author[1]/text()}
Examples:
response = context.expand('${GetDataPoints#Response) ---Json format
response = context.expand('${GetDataPoints#Response#$.params[2].options[0].id}') ---Json format
'.'表示当前json对象
/**
*<Results>
* <ResultSet fetchSize="128">
* <Row rowNumber="1">
* <ID>0Axxxxx</ID>
* <aaaY>4</aaaY>
* </Row>
* </ResultSet>
*</Results>
*/
responseAsXml = context.expand( '${JDBC Request#ResponseAsXml') ---Xml format
responseAsXml = context.expand('${JDBC Request#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/ID[1]}') --Xml format
2> Where scope can be one of the following literal values:
#Project# - references a Project property(Reference properties across a particular SoapUI project)
#TestSuite# - references a TestSuite property in the containing TestSuite
#TestCase# - references a TestCase property in the containing TestCase
Example: context.expand("${#Project#FilePath}")
context.expand("${#TestSuite#FilePath}")
context.expand("${#TestCase#FilePath}")
#MockService# - references a MockService property in the containing MockService
#Global# - references a global property. Found in File>Preferences>Global Properties tab. Reference properties across all projects
Example: Preferences -> Global Properties: test = global variables
assert context.expand("${test}") == "global variables"
#System# - references a system property. Found in Help>System properties.
Example: assert context.expand('${#System#file.encoding}') == 'GBK'
#Env# - references an environment variable
Example: context.expand('${#Env#JAVA_HOME}')
#[TestStep name]# - references a TestStep property
Example:
Property step: context.expand('${Properties#variable}')
Groovy Step: context.expand('${getSql2#result}')
Request Step: context.expand('${Request 1#Response}')
3> Dynamic Properties:
${=(int)(Math.random()*1000)}
${=request.name}
${=request.operation.interface.project.name}
${=import java.text.SimpleDateFormat ; new SimpleDateFormat("YYYY-MM-DDT00:00:00").format(new Date())}
context.expand('${=request.name}')
Test library: http://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/RestRequest.html
4> Nested Properties:
testxml = "hello"
testxpath = "//value[@id=${id}]/text()"
id = "123"
-> "${#testxml#${testxpath}}" evaluates to "hello"
1> Property Expansion in soapUI: ${Search Request#Response#//ns1:Item[1]/n1:Author[1]/text()}
Examples:
response = context.expand('${GetDataPoints#Response) ---Json format
response = context.expand('${GetDataPoints#Response#$.params[2].options[0].id}') ---Json format
'.'表示当前json对象
/**
*<Results>
* <ResultSet fetchSize="128">
* <Row rowNumber="1">
* <ID>0Axxxxx</ID>
* <aaaY>4</aaaY>
* </Row>
* </ResultSet>
*</Results>
*/
responseAsXml = context.expand( '${JDBC Request#ResponseAsXml') ---Xml format
responseAsXml = context.expand('${JDBC Request#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/ID[1]}') --Xml format
2> Where scope can be one of the following literal values:
#Project# - references a Project property(Reference properties across a particular SoapUI project)
#TestSuite# - references a TestSuite property in the containing TestSuite
#TestCase# - references a TestCase property in the containing TestCase
Example: context.expand("${#Project#FilePath}")
context.expand("${#TestSuite#FilePath}")
context.expand("${#TestCase#FilePath}")
#MockService# - references a MockService property in the containing MockService
#Global# - references a global property. Found in File>Preferences>Global Properties tab. Reference properties across all projects
Example: Preferences -> Global Properties: test = global variables
assert context.expand("${test}") == "global variables"
#System# - references a system property. Found in Help>System properties.
Example: assert context.expand('${#System#file.encoding}') == 'GBK'
#Env# - references an environment variable
Example: context.expand('${#Env#JAVA_HOME}')
#[TestStep name]# - references a TestStep property
Example:
Property step: context.expand('${Properties#variable}')
Groovy Step: context.expand('${getSql2#result}')
Request Step: context.expand('${Request 1#Response}')
3> Dynamic Properties:
${=(int)(Math.random()*1000)}
${=request.name}
${=request.operation.interface.project.name}
${=import java.text.SimpleDateFormat ; new SimpleDateFormat("YYYY-MM-DDT00:00:00").format(new Date())}
context.expand('${=request.name}')
Test library: http://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/RestRequest.html
4> Nested Properties:
testxml = "hello"
testxpath = "//value[@id=${id}]/text()"
id = "123"
-> "${#testxml#${testxpath}}" evaluates to "hello"