> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/web-unblocker/custom-browser-instructions/browser-instructions-beta/list-of-instructions.md).

# 指令列表

## 通用参数

下面定义的所有指令都具有一组一致的参数。参数如下。

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

* **类型**: `Enum["click", "input", "scroll", "scroll_to_bottom", "wait", "wait_for_element", "fetch_resource"]`
* **说明：** 浏览器指令类型。

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

* **类型**: `int`
* **说明：** 如果未能按时完成，动作在多久后被跳过。
* **限制**: 0 < `timeout_s` <= 60
* **默认值**: 5

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

* **类型**: `int`
* **说明：** 执行下一步动作前等待多久。
* **限制**: 0 < `wait_time_s` <= 60
* **默认值**: 0

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

* **类型**: `Enum["error", "skip"]`
* **说明：** 指示当此指令失败时如何处理指令：
  * `"error"`: 停止执行浏览器指令。
  * `"skip"`: 继续执行下一条指令。
* **默认值**: `"error"`

#### 通用参数示例

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

## 指令 <a href="#click" id="click"></a>

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

* **说明**: 点击一个元素并等待指定秒数。
* **参数：**
  * `type: str = "click"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
* **示例**:

{% code overflow="wrap" %}

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

{% endcode %}

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

* **说明**: 向选中的元素输入文本。
* **参数：**
  * `type: str = "input"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * `value: str`
  * **示例：**

{% code overflow="wrap" %}

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

{% endcode %}

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

* **说明**: 按指定像素数滚动。
* **参数：**
  * `type: str = "scroll"`
  * `x: int`
  * `y: int`
* **示例：**

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

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

* **说明**: 滚动到底部，持续指定秒数。
* **参数：**
  * `type: str = "scroll_to_bottom"`
* **示例**:

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

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

* **说明**: 等待指定秒数。
* **参数：**
  * `type: str = "wait"`
* **示例**:

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

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

* **说明**: 等待元素加载，持续指定秒数。
* **参数：**
  * `type: str = "wait_for_element"`
  * `selector: dict`
    * `type: Enum["xpath", "css", "text"]`
    * `value: str`
  * **示例：**

{% 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" %}
该 `fetch_resource` 该指令必须是浏览器指令列表中的最后一条；后续任何指令都不会执行。
{% endhint %}

* **说明**: 获取与指定模式匹配的第一个 Fetch/XHR 资源。
* **参数：**
  * `type: str = "fetch_resource"`
  * `filter: str(RegEx expression)`
  * `on_error: Enum["error", "skip"]`
* **示例：**

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

## 指令验证

任何关于指令格式的不一致都会导致一个 `400` 状态码和相应的错误消息。

例如，如下载荷：

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

将导致：

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/cn/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.
