# Lista de instruções

## Argumentos gerais

Todas as instruções definidas abaixo têm um conjunto consistente de argumentos. Os argumentos são os seguintes.

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

* **Tipo**: `Enum["click", "input", "scroll", "scroll_to_bottom", "wait", "wait_for_element", "fetch_resource"]`
* **Descrição:** Tipo de instrução do navegador.

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

* **Tipo**: `int`
* **Descrição:** Quanto tempo até a ação ser ignorada se não for concluída a tempo.
* **Restrições**: 0 < `timeout_s` <= 60
* **Valor padrão**: 5

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

* **Tipo**: `int`
* **Descrição:** Quanto tempo esperar antes de executar a próxima ação.
* **Restrições**: 0 < `wait_time_s` <= 60
* **Valor padrão**: 0

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

* **Tipo**: `Enum["error", "skip"]`
* **Descrição:** Indicador do que fazer com as instruções caso esta instrução falhe:
  * `"error"`: Interrompe a execução das instruções do navegador.
  * `"skip"`: Continua com a próxima instrução.
* **Valor padrão**: `"error"`

#### Exemplo com argumentos gerais

{% 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 %}

## Instruções <a href="#click" id="click"></a>

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

* **Descrição**: Clica em um elemento e espera um número definido de segundos.
* **Args:**
  * `type: str = "click"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
* **Exemplo**:

{% code overflow="wrap" %}

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

{% endcode %}

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

* **Descrição**: Insere um texto em um elemento selecionado.
* **Args:**
  * `type: str = "input"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * `value: str`
  * **Exemplo:**

{% code overflow="wrap" %}

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

{% endcode %}

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

* **Descrição**: Rola um número definido de pixels.
* **Args:**
  * `type: str = "scroll"`
  * `x: int`
  * `y: int`
* **Exemplo:**

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

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

* **Descrição**: Rola até o fim por um número definido de segundos.
* **Args:**
  * `type: str = "scroll_to_bottom"`
* **Exemplo**:

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

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

* **Descrição**: Espera um número definido de segundos.
* **Args:**
  * `type: str = "wait"`
* **Exemplo**:

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

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

* **Descrição**: Espera o elemento carregar por um número definido de segundos.
* **Args:**
  * `type: str = "wait_for_element"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * **Exemplo:**

{% 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" %}
A `fetch_resource` a instrução deve ser a instrução final na lista de instruções do navegador; quaisquer instruções subsequentes não serão executadas.
{% endhint %}

* **Descrição**: Busca a primeira ocorrência de um recurso Fetch/XHR correspondente ao padrão definido.
* **Args:**
  * `type: str = "fetch_resource"`
  * `filter: str(expressão RegEx)`
  * `on_error: Enum["error", "skip"]`
* **Exemplo:**

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

## Validação das instruções

Qualquer inconsistência em relação ao formato da instrução resultará em um `400` código de status e uma mensagem de erro correspondente.

Por exemplo, um payload como:

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

Resultará em:

```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/products/pt-br/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.
