> 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/cao-zuo-zhi-nan/switch/switch-to-popup.md).

# 切换到弹出窗口

切换到弹出窗口是指令脚本将控制权从当前浏览器窗口转移到新弹出的子窗口（弹出窗口）的操作。

#### Iframe 和弹出窗口之间的区别：

* Iframe：是嵌入在同一网页标签中的“框架”。
* 弹出窗口：是完全新开的窗口，脱离旧标签，独立运行（有标题栏和单独的最大化/最小化/关闭按钮）。

#### 配置参数：

* 弹出窗口标题：您想要切换到的弹出窗口的标题。系统采用相对搜索机制（只需弹出窗口标题包含您输入的短语，系统将自动识别并跳转）。

#### 实际示例：处理 Google 登录窗口，点击“继续使用 Google”后

继续在 Pinterest 页面上的处理流程。在您切换到 Iframe 并点击 *继续使用 Google* 按钮后，一个独立的小窗口（弹出窗口）将弹出，要求您输入 Google 的 Gmail 和密码。

此时，原始的 Pinterest 浏览器将变得模糊，所有后续操作必须在这个新窗口中进行。您可以按以下步骤配置：

* 步骤 1（激活弹出窗口）：使用命令点击 *继续使用 Google* 按钮（如在 Iframe 课程中所做）。
* 步骤 2（等待弹出窗口出现 - 如果需要）：您可以使用 Wait popup 命令或短暂延迟约 1-2 秒，以便窗口能够加载出来。
* 步骤 3（检查弹出窗口是否存在）：您可以使用 Has popup 命令。如果弹出窗口存在，返回结果为 True。
* 步骤 3（切换到弹出窗口）：将切换到弹出窗口的操作拖入流程中。
  * 弹出窗口标题：填写 `Google Accounts` *(因为这个窗口的完整标题通常很长，如“登录 - Google Accounts”，您只需填写这个特征短语，系统会自动匹配)*。
* 步骤 4（输入交互）：在此命令后，控制权已完全转移到新窗口。您可以使用 Key press 命令输入帐户、密码并正常点击“下一步”。

> 💡 返回提示：在您完成弹出窗口的登录后，Google 系统将自动检查并关闭此窗口。要继续控制原始 Pinterest 页面，您只需使用 Active tab 命令或返回主标签以继续执行后面的数据抓取操作。


---

# 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/cao-zuo-zhi-nan/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.
