> 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/switch/switch-to-popup.md).

# Switch to popup

Switch to popup là hành động ra lệnh cho kịch bản dịch chuyển quyền điều khiển từ cửa sổ trình duyệt hiện tại sang một cửa sổ con mới vừa được bật lên (Popup Window).

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

#### Sự khác biệt giữa Iframe và Popup:

* Iframe: Là một "khung tranh" nằm nhúng bên trong cùng một tab trang web.
* Popup: Là một cửa sổ hoàn toàn mới xé toạc ra khỏi tab cũ, hoạt động độc lập (có thanh tiêu đề và nút phóng to/thu nhỏ/tắt riêng).

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

* Popup Title: Tiêu đề của cửa sổ popup bạn muốn chuyển sang. Hệ thống áp dụng cơ chế tìm kiếm tương đối (chỉ cần tiêu đề popup chứa cụm từ bạn nhập là hệ thống sẽ tự động nhận diện và nhảy vào).

#### Ví dụ thực tế: Xử lý cửa sổ đăng nhập Google sau khi bấm "Continue with Google"

Tiếp tục luồng xử lý trên trang Pinterest ở bước trước. Sau khi bạn chuyển vào Iframe và click vào nút *Continue with Google*, một cửa sổ nhỏ (Popup) độc lập sẽ bật ra ngoài màn hình để yêu cầu bạn điền Gmail và Password của Google.

Lúc này, trình duyệt gốc Pinterest sẽ bị mờ đi, và toàn bộ thao tác tiếp theo phải được thực hiện trên cái cửa sổ mới này. Bạn cấu hình như sau:

* Bước 1 (Kích hoạt mở Popup): Dùng lệnh click vào nút *Continue with Google* (như đã làm ở bài học Iframe).
* Bước 2 (Chờ Popup xuất hiện - Nếu cần): Bạn có thể dùng lệnh Wait popup hoặc Delay ngắn khoảng 1-2 giây để cửa sổ kịp tải ra.
* Bước 3 (Kiểm tra Popup có tồn tại không): Bạn có thể dùng lệnh Has popup. Nếu popup tồn tại, kết quả trả về là True.
* Bước 3 (Chuyển sang Popup): Kéo hành động Switch to popup vào luồng.
  * Popup Title: Điền chữ `Google Accounts` *(Vì tiêu đề đầy đủ của cửa sổ này thường rất dài như "Sign in - Google Accounts", bạn chỉ cần điền cụm từ đặc trưng này là hệ thống tự khớp)*.
* Bước 4 (Tương tác nhập liệu): Sau lệnh này, quyền kiểm soát đã nằm trọn trong cửa sổ mới. Bạn tiến hành dùng các lệnh Key press để nhập tài khoản, mật khẩu và bấm Tiếp theo như bình thường.

> 💡 Mẹo quay về: Sau khi bạn hoàn tất đăng nhập ở cửa sổ Popup, hệ thống Google sẽ tự động kiểm tra và đóng cửa sổ này lại. Để tiếp tục điều khiển trang Pinterest gốc, bạn chỉ cần dùng lệnh Active tab hoặc quay về tab chính để chạy tiếp các hành động cào dữ liệu phía sau.

<figure><img src="/files/WnE77BQu2oXrxdMHqWcs" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/YkUIymCe9XMZUfR5hD1D" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/WnbxnlGH2fyJ5ZjCnIK8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/QwyENng4Ac24iNOX1Pym" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/xxp8OtMh9SJ9Lx9JbQxc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/pv1MwL5A8ol1HLCkWioX" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/4AqZ81pm6ex4Jc1j9mTp" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2lWT2kvqeT0SgjUkGGS8" alt=""><figcaption></figcaption></figure>


---

# 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/switch/switch-to-popup.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.
