A simple extractor selects a string or a value from a response. To create it:
1. Select the request or an existing extractor in the test case tree,
2. Right-click and choose Create Response Extractor.
3. The extractor control will appear. It displays four areas:
Note: Most often, response content is text-based, and it is displayed in the response window as a clear text. Compressed and/or encrypted text-based responses are automatically decompressed /decrypted and displayed as clear text as well. WCF binary responses are decoded and displayed as XML.
3. Select the extractor type.
5. Complete an optional description and fill out other required properties defining a text search rule that depends on the extractor type.
4. Give it a unique and meaningful name. It will appear in the Variable Picker when you create parameters.
6. Verify the Extractor.
7. Click Save & Close. To generate more extractors, click Save & New.
Once the extractor is created, you can edit it. To do so, select the extractor node on the Workflow Tree (e), right-click the extractor you wish to edit (f), and then in the context menu choose Edit (g) or double-click on the extractor. You can also click edit (h) on the toolbar instead. The same extractor control will appear. Change the extractor's properties, verify it, and save changes.
Info: When opening an extractor for editing or reviewing, the extracted value will be highlighted in the response window.
Extractor from Extractor
Sometimes it is necessary to create an extractor that selects a string or a value from another extractor. An example when this would be useful is when the response body contains XML or JSON content intermingled with other content. The easiest way to extract value from XML or JSON is by creating an XPath or JPath extractor, respectively. If you create a simple extractor from the body, it will fail while parsing parts of the body that are not XML or JSON.
You can resolve this issue in two steps:
1. Create a simple text delimiter extractor which selects the entire XML or JSON block from the body, as described above.
2. Create an XML or JSON extractor from the simple extractor. To do so, right-click on the existing extractor (i) and then in the context menu, select Create Response Extractor (j). The same extractor control will appear. The response window (d) will display the content of the first simple extractor instead of the response content. Continue configuring the extractor as you would the simple extractor.
Note: Extractors can be created from other extractors in unlimited levels. Multiple related extractors are evaluated sequentially at run-time, starting from the top simple extractor down the chain to the last extractor.
See also: Custom Patterns
- No labels