About Property Transfer test step
The Property Transfer test step transfers property and parameter values from one place in your tests to another. For example, you can use it to transfer data from a response to subsequent requests.
During the test run, the test step performs all transfers you created in order. At design time, you can run individual transfers to check how they work.
When a transfer runs, ReadyAPI replaces the value of the target property with the value of the specified source property. You can specify a particular node in the source and target properties by using XPath, XQuery or JSONPath expressions. In this case, ReadyAPI replaces the value of the specified target node with the specified source node.
ReadyAPI cannot parse XML documents that contain the byte order mark (BOM) character. |
Editing Property Transfer test step
You can modify test step settings in its editor:
Here is a brief description of the editor’s panels:
Transfer list
Transfers to be performed during the test. Use the toolbar to create and modify transfers:
-
– Adds a new transfer to the list.
-
– Removes the selected transfer from the list.
-
– Creates a copy of the selected transfer.
-
– Renames the selected transfer.
-
and – Move the selected transfer up and down in the list respectively.
-
/ – Disables or enable the selected transfer.
Test step toolbar
The main test step toolbar. It contains the following commands:
-
– Run the selected transfer.
Both source and target properties must be available. For example, to transfer data from a response, make sure to run the corresponding request. -
– Run all the transfers.
Both source and target properties must be available. For example, to transfer data from a response, make sure to run the corresponding request. -
– Declare namespaces in both the source and destination XPath fields. ReadyAPI extracts namespaces from the specified requests.
Source
Specifies a property from which ReadyAPI will obtain data for a transfer.
If the source property contains XML or JSON data, you can use an XPath, XQuery or JSONPath expression to extract the needed value from the property.
-
Source – The test item containing the source property.
-
Property – The property containing the value to transfer.
-
Path language – The language of the source selection expression. Possible values: XPath, XQuery or JSONPath.
-
– Open a dialog you use to select the source value.
-
The text box at the bottom of the Source panel specifies an XPath, XQuery or JSONPath expression used to obtain the desired node. You can enter it manually or click and select the needed item.
Target
Specifies a property that ReadyAPI will replace with the transferred data.
If the target property contains XML or JSON data, you can use an XPath, XQuery or JSONPath expression to replace only the specified element or attribute.
-
Target – The test item containing the target property.
-
Property – The property to which the value will be transferred.
-
Path language - The language of the target selection expression. Possible values: XPath, XQuery or JSONPath.
-
– Open a dialog you use to select the target value.
-
The text box at the bottom of the Target panel specifies an XPath, XQuery or JSONPath expression used to obtain the node to which the value will be transferred. You can enter it manually or click and select the needed item.
Options
Contains options that modify transfer behavior. Select the options you need to modify the transfer parameters.
-
Fail Transfer on Error – If selected, ReadyAPI considers the test step as failed when an error occurs during a transfer. In this case, it will not perform the further transfers on the list.
-
Transfer Text Content – If this option is enabled, the transfer will extract text data from the source and transfer it. Only the text content will be transferred. Structure elements will not be preserved.
Otherwise, if the source returns a hierarchy of XML nodes or JSON objects, it transfers the nodes (objects).
If the Transfer Child Nodes option is enabled, this option is ignored. -
Transfer to all – A transfer to all matching transfer selections.
If selected, the test step assigns the transferred data to all the objects that the Target property specifies. For example, this can happen if Target XPath returns several XML elements.
The matched values will be transferred to all the target locations if there are several matches.
-
Entitize Transferred Value(s) – If selected, the test step will escape special characters such as
&
,<
or>
in the transferred data. Do not use it if the data is already escaped. -
Set Null on Missing Source – Specifies whether the test step assigns
null
to the target property if the source property is missing. If the check box is selected and the source is missing, the target's property value will be lost.Works only when the Fail transfer on error option is disabled. -
Ignore empty/missing values – Specifies whether the test step transfers empty values. Select this check box, if you do not want to change the target when the source is empty. If the matched value of the source is empty or missing, it will be ignored and the target value will be left as it was.
Works only when the Fail transfer on error option is disabled. -
Transfer Child Nodes – If this option is selected and the source contains XML nodes or JSON objects, the test step transfers XML nodes or JSON objects rather than text data. This setting overrides the Transfer text content option.
Property list
Besides the test step editor, you can adjust the test step’s behavior by using its properties in the Property Transfer Properties tab in the Navigator.
Note: | The Property Transfer test step does not support custom properties. |
Property Transfer Properties | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Name |
The test step’s name. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
Logging
While the test step editor is open, brief information about performed transfers is listed in the Transfer Log panel. If the test step is run as part of a test case, you can see the transfer log in the Transaction Log panel.
To clear the log, click .
The log table contains the following columns:
Column | Description |
---|---|
Timestamp | Specifies the time when a transfer happened. |
Transfer Name | The name of the transfer. |
Transferred Values | The values that were transferred. |
Working with
Below, you can find information on common tasks that you can perform by using the Property Transfer test step.
Create transfer
A new test step does not contain any transfers. To create one, click .
When you create the transfer, it automatically sets the previous test step as the source and the next test step as the target. If there is no data to get from the previous test step or there are no further test steps, the corresponding field will be empty.
Abort execution
The test case execution is only aborted if the Fail On Error option is enabled.
Extract session ID from response
One of the common cases of using the Property Transfer test step is extracting a value from response data and using it in further requests. This example shows how to extract the session ID from a response.
-
Add a login request to an empty test case and execute it so that you have a valid response to work with.
-
Create the Property Transfer test step after the request and add a transfer to it.
By default, a transfer uses the previous request as the source and the next step as a target. If there is no next step, the target will be empty.
-
Configure the source property to be the response of the login request and then click .
It opens the Property Expansion wizard for selecting the desired source node to transfer from.
The dialog is a Pro feature and requires a ReadyAPI Test license. In the Basic version, you need to add the JSONPath expression manually. -
Select the node containing the
sessionid
value. -
Click OK.
ReadyAPI will generate the corresponding JSONPath statement:
The source is set up and the next step is to configure the target for the property transfer.
Write property directly to target test step
This example shows how to transfer a property to the target test step where the value should be used. This is easier if you just want to use the value in one place. This approach is more straight-forward than transferring to temporary properties.
-
Assume that we have a configured property transfer source:
-
Set the target as the needed request and click to use the JSONPath Property Expansion wizard to create the target JSONPath statement.
The wizard is a pro feature and requires a ReadyAPI Test license. In the Basic version , you need to add the JSONPath expression manually. -
In the ensuing dialog, select the node to transfer the value to:
Write to temporary property
You can write the transferred property to a temporary property that can be referred to by all subsequent test steps that need to use the sessionID. This solution is the best if you want to use the sessionID in several places or test steps.
Assume that we have a configured property transfer source:
We can now add it to a test case property and use it as a variable for all the test steps in the test case. To do this:
-
Save the property to the test case "SessionID" property:
-
Click to run the created transfer. SessionID is transferred to the specified test case property and can be used in any request by adding Property Expansions or other property transfer. For example in a logout request, we could have:
<logout>
<sessionID>${#TestCase#SessionID}</sessionID>
</logout>This replaces the expansion with the saved
SessionID
when the request is sent.
See Also
Transferring Property Values
Property Wait Test Step
Properties Test Step
Test Steps