# Lista de instrucciones

## Argumentos generales

Todas las instrucciones definidas a continuación tienen un conjunto consistente de argumentos. Los argumentos son los siguientes.

### `type` <a href="#type" id="type"></a>

* **Tipo**: `Enum["click", "input", "scroll", "scroll_to_bottom", "wait", "wait_for_element", "fetch_resource"]`
* **Descripción:** Tipo de instrucción del navegador.

### `timeout_s` <a href="#timeout_s" id="timeout_s"></a>

* **Tipo**: `int`
* **Descripción:** Tiempo hasta que la acción se omite si no se completa a tiempo.
* **Restricciones**: 0 < `timeout_s` <= 60
* **Valor por defecto**: 5

### `wait_time_s` <a href="#wait_time_s" id="wait_time_s"></a>

* **Tipo**: `int`
* **Descripción:** Tiempo de espera antes de ejecutar la siguiente acción.
* **Restricciones**: 0 < `wait_time_s` <= 60
* **Valor por defecto**: 0

### `on_error` <a href="#on_error" id="on_error"></a>

* **Tipo**: `Enum["error", "skip"]`
* **Descripción:** Indicador de qué hacer con las instrucciones en caso de que esta instrucción falle:
  * `"error"`: Detiene la ejecución de las instrucciones del navegador.
  * `"skip"`: Continúa con la siguiente instrucción.
* **Valor por defecto**: `"error"`

#### Ejemplo con argumentos generales

{% code overflow="wrap" %}

```bash
{\"type\": \"wait_for_element\", \"selector\": {\"type\": \"text\", \"value\": \"Load More Items\"},\"timeout_s\": 5, \"wait_time_s\": 2, \"on_error\": \"skip\"}
```

{% endcode %}

## Instrucciones <a href="#click" id="click"></a>

### `click` <a href="#click" id="click"></a>

* **Descripción**: Hace clic en un elemento y espera una cantidad determinada de segundos.
* **Args:**
  * `type: str = "click"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
* **Ejemplo**:

{% code overflow="wrap" %}

```bash
{\"type\": \"click\",\"selector\": {\"type\": \"xpath\",\"value\": \"\/\/button\"}}
```

{% endcode %}

### `input` <a href="#input" id="input"></a>

* **Descripción**: Ingresa un texto en un elemento seleccionado.
* **Args:**
  * `type: str = "input"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * `value: str`
  * **Ejemplo:**

{% code overflow="wrap" %}

```bash
{\"type\": \"input\",\"selector\": {\"type\": \"xpath\",\"value\": \"\/\/input\"},\"value\": \"pizza boxes\"}
```

{% endcode %}

### `scroll` <a href="#scroll" id="scroll"></a>

* **Descripción**: Desplaza una cantidad determinada de píxeles.
* **Args:**
  * `type: str = "scroll"`
  * `x: int`
  * `y: int`
* **Ejemplo:**

```bash
{\"type\": \"scroll\",\"x\": 0,\"y\": 100}
```

### `scroll_to_bottom` <a href="#scroll_to_bottom" id="scroll_to_bottom"></a>

* **Descripción**: Desplaza hasta el final durante una cantidad determinada de segundos.
* **Args:**
  * `type: str = "scroll_to_bottom"`
* **Ejemplo**:

```bash
{\"type\": \"scroll_to_bottom\",\"timeout_s\": 10}
```

### `wait` <a href="#wait" id="wait"></a>

* **Descripción**: Espera una cantidad determinada de segundos.
* **Args:**
  * `type: str = "wait"`
* **Ejemplo**:

```bash
{\"type\": \"wait\",\"wait_time_s\": 2}
```

### `wait_for_element` <a href="#wait_for_element" id="wait_for_element"></a>

* **Descripción**: Espera a que un elemento se cargue durante una cantidad determinada de segundos.
* **Args:**
  * `type: str = "wait_for_element"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * **Ejemplo:**

{% code overflow="wrap" %}

```bash
{\"type\": \"wait_for_element\",\"selector\": {\"type\": \"text\",\"value\": \"Load More Items\"},\"timeout_s\": 5}
```

{% endcode %}

### `fetch_resource` <a href="#fetch_resource" id="fetch_resource"></a>

{% hint style="warning" %}
La `fetch_resource` instrucción debe ser la instrucción final en la lista de instrucciones del navegador; cualquier instrucción posterior no se ejecutará.
{% endhint %}

* **Descripción**: Recupera la primera ocurrencia de un recurso Fetch/XHR que coincida con el patrón establecido.
* **Args:**
  * `type: str = "fetch_resource"`
  * `filter: str(RegEx expression)`
  * `on_error: Enum["error", "skip"]`
* **Ejemplo:**

```bash
{\"type\": \"fetch_resource\",\"filter\": \"\/graphql\/item\/\"}
```

## Validación de las instrucciones

Cualquier inconsistencia con respecto al formato de la instrucción resultará en un `400` código de estado y un mensaje de error correspondiente.

Por ejemplo, una carga útil como la siguiente:

```bash
[{\"type\": \"unsupported-wait\",\"wait_time_s\": 5}]}]
```

Resultará en:

```json
{    
    "errors": {
        "message": "Unsupported action type `unsupported-wait`, choose from 'click,fetch_resource,input,scroll,scroll_to_bottom,wait,wait_for_element'"
    }
}
```


---

# 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://developers.oxylabs.io/documentation/es/soluciones-avanzadas-de-proxy/web-unblocker/custom-browser-instructions/browser-instructions-beta/list-of-instructions.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.
