One of the key Qualibrate features is the ability to store information from the applications under test. Sometimes, users are interested in storing portions of large texts generated by the application, and Qualibrate gives users the ability to search parts of the text that they would like to store.
Example
Full Text | Document 4500017748 successfully created |
To Store | 4500017748 |
Procedure
To store the number, we can use an advanced JavaScript code snippet to save only the portion needed from the full text. To do that, follow this procedure.
Open the Recorder widget
When the text you want to store appears, click the Store button in the Recording widget
Select the control where the text appears
After the “Store” step is added:
Expand the recording control
Click the “Configuration” button
Go to the Advanced configuration tab
In the code editor, paste the following code:
return obj.innerText.split(' ')[1]
Save the configuration
Click “Save” in the recording widget
Want other parts of the text?
The code above splits the text into parts divided by a space key (' '). Each part is saved into a text array in which elements can be accessed by their index (enclosed in brackets, starts from 0). The text from this example is composed by 4 parts, which can be accessed as follows:
Full Text | Document 4500017748 successfully created |
Document | [0] |
4500017748 | [1] |
successfully | [2] |
created | [3] |
Comments
0 comments
Please sign in to leave a comment.