Get position

Description

Gets an element coordinates and size using the element's selector. The 'Save value to variable' block appears automatically when choosing the 'Get position' function. It automatically saves the value to a variable. However, the block is not mandatory to use and can be removed from the workflow.

Parameters

Change the element

Enables you to manually specify an element. Once the element is chosen, a list of attributes appears. These attributes can be excluded or included.

If the 'Use focused element' option is selected then the robot will get the position of the element where the cursor is located.

Comment

Contains an annotation to the block. The input text will be displayed inside the block above the function name.

Result

The received coordinates and size are stored in element_bounds variable by default. The variable represents an object with the following keys:

Keys and values of an object with the coordinates and size information
{
"y": "y coordinate of the top left corner of the rectangle with the element",
"x": "x coordinate of the top left corner of the rectangle with the element",
"height": "height of the rectangle with the specified element",
"width": "width of the rectangle with the specified element",
"bottom": "y coordinate of the bottom side of the rectangle with the element",
"top": "y coordinate of the top side of the rectangle with the element",
"right": "x coordinate of the right side of the rectangle with the element",
"left": "y coordinate of the left side of the rectangle with the element"
}

Usage Examples

This function may be considered a kind of an 'anchor'. Suppose we have an element with a reliable selector but we are required to interact with another element with unstable selector. Assume we know that the distance between the 'stable' and 'unstable' elements is always fixed. In this case, we could then locate the first, that is stable, element position and then calculate a relative distance to the unstable element.