Skip to main content

Action Constructor and XPath Search

🔗 Original page — Source of this material


Description

The Action Constructor is a universal tool for working with page elements, allowing you to select the most suitable identifiers for finding them.

Attention

To use this feature, you’ll need some basic knowledge of HTML markup.

How to open it?

There are two ways to open the constructor:

  1. Right-click the element you’re interested in on the page and choose *Send to Action Constructor from the ❗→ context menu.

image-20200809-145400

  1. The second way is from the ❗→ Element Tree window. Right-click the desired element and select *Send to Action Constructor.

image-20200809-164607

Note

When you add an element to the Action Constructor, its available properties and attributes are automatically added to the Properties window.

Search parameters

image-20200809-152818

Document number

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

Form number

It’s also best to set this to -1 (search in all forms on the page). By doing this, your template will be more universal.

> > Example: There are 3 forms on the page—search, registration, and product order. Suppose you need to click a button in the order form, and you select “Form” value as 2 (index starts at zero). Sometime later, a new login form appears on the site and is inserted before the order form. Now number 2 will be the login form, and your template will either throw an error saying it can’t find the button, or (even worse) it’ll click a different button in a different form.

Note

In the program settings (Settings → Recording), you can check “Search in all forms on the page” and “Search in all documents on the page” so that the number for document and form will always be -1 when finding elements.

Tag

The HTML tag you want to find.

Example:
<div class="visible" id="username"></div>
div is the tag.

Attribute name

The attribute of the HTML tag you’ll search by.

<div class="visible" id="username"></div>
class and id are attributes.

Value

The value of the selected HTML tag’s attribute.

<div class="visible" id="username"></div>
visible and username are attribute values.

Search type

  1. text - search by full or partial text
  2. notext - searches for elements that do not contain the specified text
  3. regexp - search using ❗→ regular expressions By default, the search is case-insensitive. To make a regular expression case-sensitive, add (?-i) at the start of the expression (this disables case-insensitive search).

As shown in the screenshot, after clicking the *Search button, three elements were found. This isn’t ideal—always try to pick search parameters so that only one element is found.

With ❗→ XPath expressions, you can create a more universal and robust element search algorithm compared to classic search or regular expressions.

image-20200809-153104

Document number and Form number work the same as in Classic Search.

XPath

Field for entering your ❗→ XPath expression.

Variants

Here you can select one of the suggested *Constructor expressions.

Note

If none of the suggested options suit you, you can write your own XPath expression.

Choosing an action

You can select one of three possible actions

Set - ❗→ Set value
image-20200809-170409

  • Attribute — the attribute of the element where you want to set a new value
  • Value — the text you want to insert. You can use plain text or project variables like { -Variable.someVar- }, { -Profile.Name- }.

Get❗→ Get value
image-20200809-155322

  • Attribute — the attribute whose value you want to get.
  • Value — this will display the value of the found attribute.

Rise❗→ Perform action
image-20200809-155243

  • here you can choose the necessary action to perform on the found element.

image-20200809-170449

  • For *drag and *drop actions, there are two extra fields for coordinates.

Final steps

image-20200809-155614

Testing

After picking the necessary search parameters and selecting the needed action, it’s a good idea to test your parameters by clicking the corresponding button.

Comment

It’s a good idea to leave a comment for the action, since automatic comments tend not to be very informative.

Default comments

image-20200809-161201

The same actions, but with your own comments

image-20200809-161401

Adding to project

Once you’ve chosen the right parameters, found the element, and selected and tested the needed action, you can click *Add to project.