> 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/huong-dan-cac-action/scroll/scroll-to-element.md).

# Scroll to element

Hành động này ra lệnh cho trình duyệt tự tính toán và cuộn trang một cách thông minh cho đến khi phần tử (element) bạn chọn xuất hiện ngay trong tầm nhìn của màn hình.

* Tác dụng: Đảm bảo phần tử mục tiêu luôn nằm trong vùng quan sát trước khi tool thực hiện click hoặc lấy dữ liệu. Việc cuộn chính xác giúp giảm lỗi "phần tử không nằm trong viewport" thường gặp ở các trang web dài hoặc có tải lười (lazy loading).

🎥 Xem thêm video hướng dẫn: [Tại đây](https://youtu.be/cCTEtuMtz-s).

#### Tham số cấu hình:

* XPath: Đường dẫn mã định danh (XPath) của phần tử mục tiêu mà bạn muốn đưa vào tầm nhìn (Ví dụ: `//button[@id="btn-load-more"]` hoặc `//div[@class="footer-section"]`).

#### Ví dụ thực tế: Đưa nút bấm bị khuất vào màn hình trước khi click

Nhiều trang web hiện đại áp dụng công nghệ chặn tương tác ngầm (bảo mật bẫy bot). Nếu một nút bấm (ví dụ: nút "Xem thêm" hoặc nút "Xác nhận thanh toán") đang nằm ẩn sâu phía dưới giao diện và chưa được cuộn tới, việc bạn ra lệnh `Mouse click` trực tiếp vào XPath của nút đó có thể bị hệ thống báo lỗi hụt, hoặc trang web từ chối ghi nhận lệnh bấm do chưa có hành vi cuộn chuột của người dùng.

* Cách cấu hình:
  1. Kéo hành động Scroll to element vào luồng ➔ Điền XPath của nút bấm mục tiêu.
  2. Kéo tiếp hành động Mouse click (hoặc Wait element) ngay phía sau để thực hiện tương tác.
* Kết quả: Trình duyệt sẽ tự động cuộn màn hình mượt mà xuống đúng vị trí có chứa phần tử đó, đưa nó hiển thị rõ ràng trên giao diện, giúp lệnh click tiếp theo diễn ra thành công 100% như người dùng thật.


---

# 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/huong-dan-cac-action/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.
