# Set Focus on Object

This is a pre-built Action located under the **@Custom Element**. The functionality of this Action in Avo Assure is to set the focus on the element or object specified in the input. The result is stored in the given dynamic variable for further use during test execution.

{% hint style="info" %}
The **Set Focus on Object** action works only when the **VerifyExists** action is executed in a preceding step.
{% endhint %}

## Syntax

**Input Value**: `<ObjectType>;<VisibleText(Optional)>;<Index>;<abs(optional)>`&#x20;

| Argument                            | Description                                                                                                                                            |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>\<ObjectType><br>(Required)</p>  | Provide the type of object which you want to set focus.                                                                                                |
| <p>\<VisibleText><br>(Optional)</p> | Provide the visible text associated with the object.                                                                                                   |
| <p>\<Index><br>(Required)</p>       | <p>Provide the position of the object you want to identify based on its sequence in the application.<br><strong>Note</strong>: Index start from 0.</p> |
| <p>\<abs><br>(Optional)</p>         | Provide the absolute XPath of the object you want to identify for this operation.                                                                      |

{% hint style="info" %}
**Note**:

* If the last argument **abs** is defined, the action executes using absolute identification based on the specified absolute XPath provided in the input.
* To skip an optional input value, use an extra semicolon (;).
  {% endhint %}

**Output Value**: `<Dynamic Variable>(Optional);<Dynamic Variable>(Optional)`

| Argument                                                    | Description                                                       |
| ----------------------------------------------------------- | ----------------------------------------------------------------- |
| \<Dynamic Variable>(Optional);\<Dynamic Variable>(Optional) | Both dynamic variable stores the status as **True** or **False**. |

### **Example 1: Setting Focus on a UI Element**

In this example, we explain how to bring focus to a specific UI element on the application interface using the provided identification details.

* **Action**: Set Focus on Object
* **Input Value**: button;;0
  * The first argument (**button**) specifies the object type to be identified.
  * The second argument is left blank to skip an optional value.
  * The third argument (**0**) specifies the index of the object when multiple matching elements are present.
* **Output Value**: {Status}
  * The result of the focus operation is stored in the **{Status}** dynamic variable, with the following possible values:
    * True: If the focus is set successfully on the element.
    * False: If the focus is not set successfully on the element.
* **Logical Explanation**: The **Set Focus on Object** action reads the identification details from the **Input Value** column (**button;;0**). The action locates the matching UI element based on the specified object type and index and applies focus to it. The execution result of the focus action (True) is stored in the **{Status}** variable.

<figure><img src="/files/qpLIG40wqjaFqEq42ttK" alt=""><figcaption></figcaption></figure>

### **Example 2: Setting Focus on a UI Element using Optional Parameters**

In this example, we are explaining how to bring focus to a specific UI element on the application interface using optional identification parameters.

* **Action**: Set Focus on Object
* **Input Value**: button;Click Me;2
  * The first argument (**button**) specifies the object type to be identified.
  * The second argument (**Click Me**) specifies the visible text of the object.
  * The third argument (**2**) specifies the index of the object when multiple matching elements are present.
* **Output Value**: {Status}
  * The result of the focus operation is stored in the **{Status}** dynamic variable, with the following possible values:
    * **True**: If the focus is set successfully on the element.
    * **False**: If the focus is not set successfully on the element.
* **Logical Explanation**: The **Set Focus on Object** action reads the identification details from the **Input Value** column (**button;Click Me;2**). The action locates the matching UI element based on the specified object type, visible text, and index, and applies focus to it. The execution result of the focus action (True) is stored in the **{Status}** variable.

<figure><img src="/files/N18jreIwCUEUcP3j5HET" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/web/custom-1/set-focus-on-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
