# Upload a File

This is a pre-built Action located under the **@Custom Element**. The functionality of this Action in Avo Assure is to upload a file to the object specified in the input by providing the file path from the local system. The result is stored in the given dynamic variable for further use during test execution.

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

## **Syntax**

**Input Value**: `<ObjectType>;<VisibleText(Optional)>;<Index>;<file path>;<file name><wait(in seconds)>;<abs(Optional)>`&#x20;

| Argument                                  | Description                                                                                                                                            |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>\<ObjectType><br>(Required)</p>        | Provide the object type which you want to perform the get image similarity percentage operation. (e.g., Image)                                         |
| <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>\<file path><br>(Required)</p>         | Provide the path of the file which you want to upload.                                                                                                 |
| <p>\<file name><br>(Required)</p>         | Provide the name of the file.                                                                                                                          |
| <p>\<wait (in seconds)><br>(Optional)</p> | Provide the wait time (in seconds) you want before performing the action.                                                                              |
| <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 (;).
* If the **wait (in second)** input is specified, the action is performed after the specified wait duration.
  {% 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: Uploading a File to an Input Field**

In this example, we are explaining how to upload a specified file to a selected input field in the application interface.

* **Action**: Upload a File
* **Input Value**: input;;0;C:\Documents\Reports;Report\_Q2.pdf;3
  * The first argument (**input**) 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 input field when multiple matching elements are present.
  * The fourth argument (**C:\Documents\Reports**) specifies the directory path where the file is located.
  * The fifth argument (**Report\_Q2.pdf**) specifies the name of the file to be uploaded.
  * The sixth argument (**3**) specifies the wait time (in seconds) before performing the upload operation.
* **Output Value**: {Status}
  * The result of the file upload operation is stored in the **{Status}** dynamic variable.
    * **True**: If the file is uploaded successfully.
    * **False**: If the file is not uploaded.
* **Logical Explanation**: The **Upload a File** action reads the identification details, file path, file name, and wait time from the **Input Value** column (**input;;0;C:\Documents\Reports;Report\_Q2.pdf;3**). The action locates the matching input field based on the specified object type and index, waits for the defined duration, and uploads the specified file to the input field. The execution result of the upload operation (True) is stored in the **{Status}** variable.

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

### **Example 2: Uploading a File using Optional Parameters**

In this example, we are explaining how to upload a specified file to a selected input field in the application interface using optional identification parameters.

* **Action**: Upload a File
* **Input Value**: input;upload;0;C:\Documents\Reports;Report\_Q2.pdf;3
  * The first argument (**input**) specifies the object type to be identified.
  * The second argument (**upload**) specifies the visible text or identifier of the input field.
  * The third argument (**0**) specifies the index of the input field when multiple matching elements are present.
  * The fourth argument (**C:\Documents\Reports**) specifies the directory path where the file is located.
  * The fifth argument (**Report\_Q2.pdf**) specifies the name of the file to be uploaded.
  * The sixth argument (**3**) specifies the wait time (in seconds) before performing the upload operation.
* **Output Value**: {Status}
  * The result of the file upload operation is stored in the **{Status}** dynamic variable.
    * **True**: If the file is uploaded successfully.
    * **False**: If the file is not uploaded.
* **Logical Explanation**: The **Upload a File** action reads the identification details, file path, file name, and wait time from the **Input Value** column (**input;upload;0;C:\Documents\Reports;Report\_Q2.pdf;3**). The action locates the matching input field based on the specified object type, visible text, and index, waits for the defined duration, and uploads the specified file. The execution result of the upload operation (True) is stored in the **{Status}** variable.

<figure><img src="/files/gomszyKPqeBbjXQ0Tsl4" 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/upload-a-file.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.
