Let's take an example https://lessons.zennolab.com/en/registration . Let's say you want to get the text of a button that submits a form. To do this, right-click on this button, from the context menu, select In action designer.
The data for the search will be automatically selected so that only one item remains in the search result. Your actions
In the Action item, select Get(1 ).
The button text is stored in the value attribute, that's why we select it from the Attribute(2) drop-down list. In the Value field will appear what is stored in the selected attribute (2) , in our case it is the text “Create an account”.
Before adding an action to the project, it will not be superfluous to test its work by clicking the appropriate button (especially if you made changes in the action designer).
(Optional, but desirable) Add a comment to the action (especially for the Get value action because the default comment is very uninformative)
Add an action to the project by clicking the Add to project button
What is it used for?
Parsing data (although there is a more suitable tool for this - the Parse the Page action)
Checking if an element is on the page This can be useful for:
determining whether we are authorized (for example, when a user is authorized on the site, a button appears to go to his personal account, if there is one, then everything is OK. Or vice versa, when the user is authorized, then some element disappears, as an option - the "Login" button, if it is not there, then we entered the site)
search for messages with errors (very useful when recognition a captcha: if the captcha was recognized incorrectly, then very often a new HTML element with the error text appears on the page; if after sending the captcha a page with such an element is returned, then we try to recognize the captcha again. Also, to check for the existence of text on the page, you can use the special action Check for text on page.)
Checking the visibility of an element: there are cases when a template finds an element, but in fact it is not displayed on the page (features of building HTML pages), for example, this is a registration button. To accurately check whether it is displayed on the page, you can take its height and width attributes, and check that each of them is more than 0.
Action Setup: Main Tab
After adding the action through the action designer to the project, open its settings:
What to take
We choose what exactly we need to get - id, class, innerText, innerHtml, value, height, width, style , etc.
In this field, you can manually specify a value, and not choose from the proposed one. On sites, you can often find the data -... attributes (examples - data-name, data-value, data-testid, data-whatever, ...) these are the attributes (which are not in the drop-down list of the action) that can be assigned manually.
By Setting ValuesandProfile Variables fill in the form fields. In a real project, we would have to recognize a captcha using services or manually , but on this page the captcha image is always the same. After entering all the data, using the Rise event action, click on the Create account button. Further events can develop in several directions:
If we filled in everything correctly and recognized the captcha correctly, we will get a page with the text Wellcome!
If the captcha is recognized incorrectly, the page with the text wrong captcha will be loaded
Using the action designer, create a Take value action that stores the text shown in the screenshots above. But a lot of unnecessary things get into the variable - the text adv_reg, the names of the menu items. Using Text Processing and Simple Regular Expression(Wellcome!|wrong\ captcha) looking for either Welcome or wrong captcha. Using Switch, we check what is contained in the variable. If there is Welcome , then we send an informational message to the log ; if wrong captcha - send a message to the log that registration failed