The Create Data Selector wizard helps you create data selectors. Data selectors are regular expressions that LoadComplete applies to server responses to extract data from them and store that data to variables for later use.
To call the wizard, right-click in the Data Selectors tabbed page of the server response and then click Create data selector with wizard.
Specifying the Data to Extract
The wizard allows creating regular expressions for the most frequent use cases visually. The following options are available:
Retrieve text - Choose this option to check whether a server response contains a specific text fragment. On the next page of the wizard, you select the text you want to extract from the response content.
The data selector will extract the selected text from the server response and store it to a variable. To check whether the variable contains the expected text, create a validation rule.
For detailed information on how to use data selectors to validate a specific text fragment of a server response, see Checking Whether a Server Response Contains Specific Text.
Get text between two values - Choose this option to extract the data located between two arbitrary strings in the response body. On the next pages of the wizard, you select strings in the response content.Show ExampleHide Example
Suppose, you need to extract the current time value from a server response:
XML<?xml version="1.0" encoding="utf-8"?>
<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">
Select the following starting and ending strings:
Text before <GetCurrentTimeResult> Text after </GetCurrentTimeResult>
The resulting regular expression will be the following:<GetCurrentTimeResult>(.*?)</GetCurrentTimeResult>
Get an input field value - Choose this option to extract data from an input field on a web page. On the next page of the wizard, you specify the name of the desired input field (the name attribute of the corresponding <input> element on the web page).
You can enter the name in the Name box or choose it from the drop-down list. You can learn the name of the needed fields on the Response Body page.Show ExampleHide Example
Suppose, the response body contains the following input field:<input name="ctMainContentUsername" type="text" value="Tester" id="ctMainContentUsername" class="txt" />
To extract the element’s value, specify its name in the Name box. The resulting regular expression will be the following:\sname\s*?\=\s*?["']?ctMainContentUsername["']?.*?\s*?value\s*?\=\s*?['"]?(.*?)['"\s]
Get text with a regular expression - Choose this option to extract arbitrary data from a server response by using a custom regular expression. On the next page of the wizard, you create the desired regular expression (either manually or by selecting predefined patterns from the popup menu) and verify that it matches the expected data.
Use text of response header - Choose this option to extract data from the response’s header. Otherwise, the created data selector will extract data from the response body.
Specifying the Regular Expression
On the Specify the regular expression to use page of the wizard, you can view the regular expression the wizard has created, or create a custom regular expression.
To simplify creation and editing of regular expressions, the wizard provides a list of the most common regular expression patterns. To add a pattern to your regular expression, click the button and select the desired pattern from the popup menu. For detailed information on the supported regular expressions, see Regular Expressions Syntax.
The page shows the response contents and highlights the text that matches the regular expression. If several text fragments match the regular expression, select the match you want to extract.
Fine Tuning the Result
On the last page of the wizard, you can view the data that the created regular expression extracts.
If the regular expression matches several text fragments, you can specify the index of the fragment you want to extract.
You can also select a conversion rule for the created data selector.
Click Finish to complete the data selector creation and close the wizard.
LoadComplete will add the created data selector to the selectors list on the Data Selectors tab. The Variable column of the Data Selectors tab will specify the variable that will store the extracted data.