> ## Documentation Index
> Fetch the complete documentation index at: https://rpa.bazhuayu.com/helpcenter/llms.txt
> Use this file to discover all available pages before exploring further.

# XPath获取元素对象

## 指令说明

**描述：** 可通过自定义写入XPath的方式定位到网页中的指定元素。

## 参数说明

<Tabs>
  <Tab title="常规">
    <img src="https://mintcdn.com/bazhuayu-rpa-docs/2nc_spg9_b4MXqPM/helpcenter/commands/web-automation/images/web-elem-obj-01.png?fit=max&auto=format&n=2nc_spg9_b4MXqPM&q=85&s=0b867f2d4afc475c7c98e3ee4f9c8804" alt="XPath获取元素对象指令参数面板" width="645" height="459" data-path="helpcenter/commands/web-automation/images/web-elem-obj-01.png" />

    | 参数               | 说明                                 |
    | ---------------- | ---------------------------------- |
    | **网页对象**         | 选择要操作的目标元素所在的网页对象                  |
    | **XPath选择器**     | 输入网页中元素的XPath（一种元素定位方式）            |
    | **元素在Iframe里**   | 目标元素是嵌套在iframe里，则需要勾选              |
    | **Iframe XPath** | 如果目标元素是嵌套在iframe里，需要填写iframe的XPath |
  </Tab>

  <Tab title="高级">
    本指令暂无高级参数。
  </Tab>
</Tabs>

## XPath获取方法

1. 在网页中右键选择“检查”，或者按键盘F12键，进入开发者模式。

<img src="https://mintcdn.com/bazhuayu-rpa-docs/2nc_spg9_b4MXqPM/helpcenter/commands/web-automation/images/web-elem-obj-xpath-01.png?fit=max&auto=format&n=2nc_spg9_b4MXqPM&q=85&s=5f3b78d7fc13bf5f07f8209e418e03bf" alt="XPath获取方法 - 打开开发者工具" width="1891" height="874" data-path="helpcenter/commands/web-automation/images/web-elem-obj-xpath-01.png" />

2. 鼠标右键点选你要定位的元素，复制元素的 XPath路径。

<img src="https://mintcdn.com/bazhuayu-rpa-docs/2nc_spg9_b4MXqPM/helpcenter/commands/web-automation/images/web-elem-obj-xpath-02.png?fit=max&auto=format&n=2nc_spg9_b4MXqPM&q=85&s=42f20492693311072d06341b1abdb54c" alt="XPath获取方法 - 复制XPath" width="1819" height="827" data-path="helpcenter/commands/web-automation/images/web-elem-obj-xpath-02.png" />

3. 将复制好的 XPath填入控件中的 「XPath选择器」。

<img src="https://mintcdn.com/bazhuayu-rpa-docs/2nc_spg9_b4MXqPM/helpcenter/commands/web-automation/images/web-elem-obj-xpath-03.png?fit=max&auto=format&n=2nc_spg9_b4MXqPM&q=85&s=8aa790e63a2622608491f446f4e14993" alt="XPath获取方法 - 填入XPath选择器" width="650" height="458" data-path="helpcenter/commands/web-automation/images/web-elem-obj-xpath-03.png" />

## 使用示例

<img src="https://mintcdn.com/bazhuayu-rpa-docs/2nc_spg9_b4MXqPM/helpcenter/commands/web-automation/images/web-elem-obj-02.png?fit=max&auto=format&n=2nc_spg9_b4MXqPM&q=85&s=43bb5089b6cfbde4485fd3d6e2d86003" alt="XPath获取元素对象使用示例 - 流程搭建" width="988" height="156" data-path="helpcenter/commands/web-automation/images/web-elem-obj-02.png" />

**该流程执行逻辑：**

使用【获取一打开的网页对象】指令来获取八爪鱼浏览器打开的网页对象

使用【XPath获取元素对象】指令，在「XPath选择器」填入\[登录]按钮的XPath，来获取登录按钮的元素对象。

### 效果展示

成功通过XPath表达式获取元素对象。

<Info>
  使用指令过程中遇到问题？前往 [八爪鱼RPA 开发者社区问答板块](https://rpa.bazhuayu.com/community/questions) 提问，获取官方与社区帮助。
</Info>
