> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/scroll/scroll-to-element.md).

# Scroll to element

此操作指示浏览器智能地自动计算并滚动页面,直到您选择的元素(element)出现在屏幕的可视范围内。

* 作用:确保目标元素在工具执行点击或获取数据之前始终位于可观察区域内。精确的滚动有助于减少在长页面或使用延迟加载(lazy loading)的网页中常见的"元素不在viewport内"的错误。

🎥 查看更多教程视频:[点击这里](https://youtu.be/cCTEtuMtz-s)。

#### 配置参数:

* XPath:您想要带入可视范围内的目标元素的标识路径(XPath)(例如:`//button[@id="btn-load-more"]` 或 `//div[@class="footer-section"]`)。

#### 实际示例:在点击之前将隐藏的按钮带入屏幕

许多现代网站应用了隐藏交互拦截技术(反机器人陷阱安全机制)。如果某个按钮(例如:"查看更多"按钮或"确认付款"按钮)隐藏在界面深处且尚未被滚动到达,那么直接对该按钮的XPath执行 `Mouse click` 指令可能会被系统报告为落空错误,或者网站因为尚未检测到用户的鼠标滚动行为而拒绝识别点击指令。

* 配置方法:
  1. 将 Scroll to element 操作拖入流程中 ➔ 填入目标按钮的XPath。
  2. 接着拖入 Mouse click(或 Wait element)操作紧随其后,以执行交互。
* 结果:浏览器将自动平滑地滚动屏幕到该元素所在的确切位置,使其在界面上清晰显示,从而帮助后续的点击指令如同真实用户操作一样100%成功执行。


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/scroll/scroll-to-element.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
