This topic explains how to extract a value so you can store it for use in another scenario step or tool.
Sections include:
A Browser Contents Viewer tool is automatically added to each scenario step recorded from the browser. You can "extract" and store data from those elements, then use those extracted values in additional tools (for instance to populate form fields or to validate data).
To store a value represented in the rendered page, complete the following from the Browser Contents Viewer’s tool configuration panel (accessible by double-clicking the tool’s node) or the Post-Action Browser Contents tab (for extraction only):
Click here to log in
”:Click
”, leave the left boundary blank and enter “ here
” (including the space) in the right boundary.here
”, enter “Click
“ in the left boundary and “to
” in the right boundary (again including spaces).in
”, enter “log
“ (including the space) as the left boundary and leave the right boundary blank.4. To send the value of the selected property to a data source (so that the value can be used later in another scenario or in another tool):
5. Click Finish.
The value will be validated or stored when the scenario is executed.
What if I don’t see the value I want to validate or extract? If the Browser Contents Viewer tool does not display the value you want to extract or validate—for example, because the related scenario step failed or because the item is not visible in the rendered page (e.g., it is a title), you can manually add a Browser Validation tool or Browser Data Bank tool. |
Need to handle dynamic attribute values? One way to handle dynamic attribute values in validations is to use partial string XPaths. To use XPaths, ensure that the Browser Validation tool’s Element Locator is set to Use XPath, then specify an appropriate XPath. For details on using XPaths, see XPath Reference. For details on using partial string XPaths, see Handing Dynamic Attribute Values - Partial String Matching Using XPath. |
Want to access the HTML content as a string? If you want to access the HTML content as a string (e.g., if you are working with a text document and you want to avoid having to predict what HTML markup the browser will add), you can add an Extension tool to the browser contents of the Browser Playback tool. To do this, you would (right-click your Browser Playback tool, then choose Add Output> Browser Contents (rendered HTML)> Extension Tool. Next, you configure the Extension tool to use an appropriate script You can retrieve the HTML for a browser window or frame using input.getHTML(). See the Javadoc for com.parasoft.api.BrowserContentsInput. The Javadocs can be accessed by choosing Parasoft> Help> Extensibility API. For example, here is a JavaScript that searches for an RFC title.
|
A Browser Data Bank tool will be chained to the Browser Playback tool. This tool will store the extracted value. The extracted value can be used wherever parameterized values are allowed, such as the value to type into an input in a subsequent scenario step or another tool. If you later want to modify the stored value, you can do so by modifying this tool’s settings.
The element that is the source of an extraction will be highlighted with a solid gray border in the Browser Contents viewer, and in the Post-Action Browser Contents tab of the Browser Data Bank tool.
To extract text to a browser data bank, complete the following:
Select the text you want to extract.
Right-click the selection, then choose Extract Selected Text into Data Bank
Ensure that the desired extraction settings appear in the dialog that opens.