Core Step invoke
Description
This step executes a request to a particular URL.
If the URL starts with a protocol (e.g. http://...) then the URL is treated is being fully qualified and invoked directly. Otherwise, the URL is treated as a relative suffix and the URL to invoke is determined from the settings specified with the config element, including port, protocol and basepath.
The result of the request is internally stored and its contents can be verified with one or more <verify...> steps. If the saveresponse option in the config element is enabled, the result (HTML source) will be written to a file for later viewing.
Note: If the URL contains an ampersand character (&), e.g. for parameter separation, it must be expressed using the XML element notion with "&".
Parameters
- url
- Required? yes
- A complete URL or the 'relative' part of an URL which will be appended to the 'static' parts created from the configuration information defined with the <config> step.
- content
- Required? no
- Form data in 'application/x-www-form-urlencoded' format, which will be sent in the body of a POST request. Ignored for GET requests. Only one of content and contentFile should be set.
- contentFile
- Required? no
- Filename to extract request contents from. Ignored for GET requests. Only one of content and contentFile should be set.
- description
- Required? no
- The description of this test step.
- method
- Required? no, default is GET
- Sets the HTTP Method, i.e. whether the invoke is a GET or POST.
- password
- Required? no
- A password that can be provided for pages that require basic authentication. Required if username is specified.
- save
- Required? no
- A shorthand: save='prefixName' is the same as savePrefix='prefixName' saveResponse='true'.
- savePrefix
- Required? no, default is the 'savePrefix' parameter as specified in <config>.
- A name prefix can be specified for making a permanent copy of received responses. A unique number and the file extension (depending on the MIME-Type) will be appended. The resultpath attribute of the <config> element is used for determining the location of the saved result.
- saveResponse
- Required? no
- Whether to make a permanent copy of received responses. Overrides the default value set in the <config> element.
- soapAction
- Required? no
- If the HTTP method is POST and is in fact a SOAP POST request, this allows the SOAP Action header to be set. Ignored for GETs.
- username
- Required? no
- A username that can be provided for pages that require basic authentication. Typically only needed on the first step of any webtest accessing a secure site. Required if password is specified.
Inline Text
The inline text is all the text between the start tag ( <invoke> ) and the end tag ( </invoke> ), including blanks, tabs or newlines. Using a pair of start/end tags ( <invoke> </invoke> ) has not the same behavior than the seemingly equivalent empty element tag ( <invoke/> )! See this issue for an example.
- Required? no
- An alternative way to set the 'url' or the 'content' attribute. When the 'url' attribute is not specified the nested text is considered as the url value. Otherwise this is used to set the 'content' attribute for e.g. large content (properties get evaluated in this content).
Details
Here is an example of a normal invoke:
<config ... />
<steps>
<invoke description="Start the main controller"
url="KycController?partnerId=012345678912&portal=RM"
save="myResultPage"/>
...
</steps>
</webtest>
Here is an example of a SOAP invoke:
<invoke method="POST" contentFile="AustralianPostcodeByLocationRequest.xml"
soapAction="http://www.webserviceX.NET/GetAustralianPostCodeByLocation"
url="http://httpwww.webservicex.com/AustralianPostCode.asmx?op=GetAustralianPostCodeByLocation"/>
<verifyText text="Karalee"/>
<verifyText text="QLD"/>
<verifyText text="4306"/>
</steps>
Note: the soapAction attribute is only needed for SOAP Web Service requests. For RESTful web services or to do an invoke of a tricky form normally submitted through JavaScript you can leave it out.
Here is what the AustralianPostcodeByLocationRequest.xml file contents might look like:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAustralianPostCodeByLocation
xmlns="http://www.webserviceX.NET">
<Location>Karalee</Location>
</GetAustralianPostCodeByLocation>
</soap:Body>
</soap:Envelope>
And the result might look something like:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetAustralianPostCodeByLocationResponse
xmlns="http://www.webserviceX.NET">
<GetAustralianPostCodeByLocationResult>
<NewDataSet>
<Table>
<Location>Karalee</Location>
<PostCode> QLD 4306</PostCode>
</Table>
</NewDataSet>
</GetAustralianPostCodeByLocationResult>
</GetAustralianPostCodeByLocationResponse>
</soap:Body>
</soap:Envelope>
WebTestRecorder