Skip to main content

Finding Elements on a Page

🔗 Original page — Source of this material


Before you interact with an element on a page, you need to find it. In the actions ❗→ Get Value , ❗→ Set Value , ❗→ Trigger Event , ❗→ Touch Event , ❗→ Swipe Event, there are two ways to search for elements – the classic method and using XPath.

Classic Method – Search by HTML element parameters: tag, attribute, and its value.

image-20200805-202115

XPath – search using ❗→ XPath expressions. This method lets you implement a more universal and layout-change-resistant way to search for data compared to classic search or regular expressions.

image-20200805-202209

Which Tab

Select the tab where the element will be searched for. Possible options:

  • Active tab
  • First
  • By name – when you choose this option, a field to enter the tab name will appear.
  • By number – in the input field, you will need to enter the tab’s sequential number (numbering starts from zero!)

Document

It’s recommended to set the value to -1 (search in all documents on the page).

Form

Also best to set -1 (search in all forms on the page). Using this value makes your template more versatile.

Why it’s better to set "-1"

Example: There are 3 forms on the page – search, registration, and order. You need to click a button in the order form, and selected 2 (two) as the value for the “Form” field (counting from zero). After a while, a new login form appears on the site, inserted before the order form. Now, number 2 will point to the login form, and your template will either give an error saying the button was not found, or (worse) click a button in the wrong form.

Tip

In the program settings, you can tick two checkboxes – Search in all forms on the page and Search in all documents on the page. Then, whenever you add an element in the Action Constructor, -1 will be set by default for document and form numbers.

Tag (classic search only)

image-20210525-095347

The actual HTML tag you want to get the value from.

Advice

You can specify several tags at once, separated by ; (semicolon)

Conditions (classic search only)

image-20210525-100053

  1. Group – priority of this condition. The higher the number, the lower the priority. If the element is not found with the highest priority condition, the search goes to the next priority, and so on, until the element is found or no conditions remain. You can add multiple conditions with the same priority; in this case, the search will check all conditions of the same priority at once.

  2. Attribute – the HTML tag attribute used for the search.

  3. Search type:

  4. text – search by full or partial text match;

  5. notext – search for elements that do not contain the specified text;

  6. regexp – search using ❗→ regular expressions By default, the search is case-insensitive. To make the regular expression search case-sensitive, add (?-i) at the beginning of the expression (this disables case-insensitive search).

  7. Value – the value of the HTML tag attribute

  8. Match No. – the sequential number of the found element (numbering starts from zero!). This field supports ❗→ using ranges and macros ❗→ for variables.

Tip

To delete a search condition, left-click the field to its left (highlighted in blue on the screenshot) and press the delete key on your keyboard.

Tip

Multiple conditions can be used to search for the desired element.

It’s always important to try to set search conditions so that only one element remains, i.e., the match number is 0 (numbering starts from zero).