Getting value
Please read the Terms of Use for Materials on ZennoLab
Table of contents
Description
This action is used to get the value of the specified element. This could be:
Height Width
Inner text \ HTML code
HTML attributes - id, class, name, style, etc.
Tag name
And much more
How to add an action to a project?
Through the context menu Add action β Tabs β Get value
Through the action designer .
Or use smart search .
How to select an element to take a value?
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.
Below, under the browser window, the Action Designer will open
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.
Project variables can be used ( {-Variable.var_name-} )
Element search
Please read the Terms of Use for Materials on ZennoLab
Table of contents
Before you can interact with an element on the page, you need to find it. In the Get Value, Set Value, Rise Event, Touch Event, Swipe Event actions, there are two ways to find items - classic and using XPath.
Classic - Search by HTML element parameters: tag, attribute and its value.
Β
Β
Β
Β
XPath - Search using XPath expressions . With the help of it you can implement a more versatile and resistant to layout changes way of data search in comparison with classic search or regular expressions.
Β
Which tab
Select the tab on which the item will be searched.
Possible values:
Active tab
First
By name - when you select this item, an input field for the name of the tab will appear.
By number - in the entry field you will need to enter the serial number of the tab (numbering starts from zero!)
Document
It is recommended to set the value -1 (search in all documents on the page).Β
Form
It is also better to set -1 (search in all forms on the page). Choosing this value will make the template more versatile.
In the program settings, you can select two checkboxes - Search all forms on the page and Search all documents on page, and then always when adding an element to the Action Designer, the document number and form will be set to -1.
Tag (classic search only)
The actual HTML tag from which you want to get the value.
You can specify several tags at once, the separator is; (semicolon)
Conditions (classic search only)
Group - the priority of this condition. The higher this number, the lower the priority. If we could not find an element by the condition with the highest priority, then go to the condition with the next priority, and so on until the element is found, or until the search conditions are over. You can add several conditions with the same priority, then the search will be performed for all conditions with the same priority at the same time.Β
Attribute - HTML attribute of the tag by which the search is performed.
Search type :
text - search by full or partial text occurrence;
notext - search for elements that do not contain the specified text;
regexp - search using regular expressions
By default RegeXp search is case insensitive. To change it you can prepend(?-i)to your expression (this mean βdisable case insensitive modeβ).
Value - the value of the HTML tag attribute
Match # - the ordinal number of the found element (numbering from zero!). Ranges and variable macros can be used in this field.
To delete a search term, left-click on the field to the left of it (highlighted in blue in the screenshot) and press the delete button on the keyboard.
Several conditions can be used to find the desired item.
It is always important to try to select search conditions in such a way that only one element remains, i.e. the serial number was 0 (numbering from zero).
Β
Action Setting: More Tab
Expectation
1. Wait before executing
How long the action will wait before executing.
2. Wait no longer than
If after the specified time the item does not appear on the page, the action will terminate with an error.
Usage example
Let's look at one of the ways to use it. For example https://lessons.zennolab.com/en/advanced .
By Setting Values and Profile 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
Useful links
Β