---
title: 云中的Puppeteer自动化
description: 使用TestingBot大规模地运行自动化的Puppeteer脚本。将你的Puppeteer脚本连接到基于云的浏览器网格。
source_url:
  html: https://zh.testingbot.com/features/automation/puppeteer
  md: https://zh.testingbot.com/features/automation/puppeteer.md
---

傀儡师云 
# 在 真实的浏览器云上运行 Puppeteer

将您现有的 Puppeteer 脚本指向 TestingBot 的网格，并在 Windows、macOS 和 Linux 上的真实 Chrome 和 Edge 浏览器中运行它们。支持大规模并行处理、视频和日志生成，符合 GDPR 标准，并支持欧盟数据驻留。

[免费开始](https://zh.testingbot.com/users/sign_up) [申请演示](https://testingbot.com/demo)

- **浏览器和操作系统:** Chrome · Edge
- **平行会议:** 100
- **正常运行时间服务级别协议:** 99.9%

被世界上一些最具创新性的公司所信任

 30秒回答 
## 为什么要在 TestingBot 上运行 Puppeteer？

真正的 Chrome 和 Edge

TestingBot 会在真实的 Windows、macOS 和 Linux 机器上，针对真实的 Chrome 和 Edge 浏览器运行您的 Puppeteer 脚本。再也不用担心“在我的笔记本电脑上用无头 Chromium 浏览器可以运行”这种意外情况了。

大规模并行

最多可同时运行 100 个 Puppeteer 会话，每个会话都在独立的虚拟机中运行。您可以选择无头模式或有头模式，每个会话均可独立设置。

录音机及其他配件

使用 Puppeteer Recorder 无需编写任何代码即可生成脚本。在同一个控制面板上测试浏览器扩展程序、抓取网页内容并运行跨浏览器并行测试套件。

 什么是木偶师？ 
## 60秒内学会操纵木偶

 ![Puppeteer](https://zh.testingbot.com/assets/support/puppeteer-0a8cdd38af69dabd46638afbb3bffc8a372902949aa599663ec379f3e875263c.svg)

### Puppeteer

Released 2017 · Chrome DevTools team · Apache 2.0

Puppeteer 是 Chrome DevTools 团队开发的 Node.js 库，它通过 DevTools 协议驱动 Chrome 和 Chromium 内核。它是最初的“无头 Chrome”自动化库，至今仍是使用 JavaScript 编写 Chrome 脚本的最快方式。

Puppeteer 提供一流的 API，用于屏幕截图、PDF、网络拦截、性能跟踪和页面指标。它是 Chrome 优先端到端测试、网页抓取和无头渲染管道的首选方案。

- Node.js 库，JavaScript / TypeScript
- Chrome、Chromium 和 Edge 通过 DevTools 协议
- 一流的屏幕截图、PDF 和网络拦截
- 无头模式和有头模式，单一 API
- 由 Chrome DevTools 团队维护

 5线设置 
## 将你的脚本指向 TestingBot 网格

重用您现有的 Puppeteer 代码。连接到 TestingBot 的 WebSocket 端点，您的脚本即可在真正的 Chrome 和 Edge 浏览器上并行运行。

connect.js step 1

```javascript
// Connect Puppeteer to TestingBot's cloud
const puppeteer = require('puppeteer-core');

const caps = {
  browserName: 'chrome',
  browserVersion: 'latest',
  platform: 'WIN11',
  'tb:options': { key: 'KEY', secret: 'SECRET' },
};

const browser = await puppeteer.connect({
  browserWSEndpoint: `wss://cloud.testingbot.com?caps=${
    encodeURIComponent(JSON.stringify(caps))}`,
});
```

login.spec.js step 2

```javascript
// Your existing Puppeteer script, unchanged
const page = await browser.newPage();

await page.goto('https://app.example.com/login');
await page.type('#user', 'jane');
await page.type('#pwd', '••••');
await Promise.all([
  page.click('#go'),
  page.waitForNavigation(),
]);

await page.screenshot({ path: 'dashboard.png' });
await browser.close();
```

有关[Puppeteer 的功能、视频录制和并行选项，请参阅 TestingBot 上的完整文档](https://testingbot.com/support/web-automate/puppeteer)。

 本地部署与云端部署 
## 本地傀儡师 vs 测试机器人

Puppeteer 在笔记本电脑上运行速度很快，但当需要扩展规模、支持多个操作系统或真正的边缘计算时，速度就会慢下来。以下是托管云的对比情况。

| 能力 | 测试机器人 | 当地木偶戏演员 |
| --- | --- | --- |
| 浏览器覆盖范围 | 真实版 Chrome 和 Edge 各版本 | 无论你本地安装了什么 |
| 操作系统 | 真正的 Windows、macOS 和 Linux | 您的单机开发机 |
| 并行扩展 | 最多可按需支持 100 个并发会话 | 受限于您的 CPU 和内存 |
| 视频和日志 | 包含高清视频、控制台日志和屏幕截图。 | 自行录制和日志采集 |
| 测试私有环境和测试环境 | 内置安全隧道 | 仅支持直接访问，不支持安全远程共享 |
| 欧盟数据驻留 | 是的，符合GDPR要求 | 无论你的笔记本电脑在哪个国家/地区 |
| 可靠性 | 99.9% 正常运行时间 SLA，全天候监控 | 合上盖子时崩溃。 |

 ![测试结果](https://zh.testingbot.com/assets/features/test-results-315382c39a67ad52167d2a4fd78570c99aea3e0ec386c17e82265851e93cb7b3.png)

 测试工件 
## 测试结果

每个测试结果都带有各种元数据；屏幕截图、日志和测试环节的视频。

从脚本中将会话标记为通过或失败，通过我们的[REST API](https://testingbot.com/support/api)获取工件，并将结果发送回 Jira、Slack 或您选择的 CI。

- 每节课均提供全高清视频
- 控制台和开发者工具日志
- 按需提供屏幕截图和 PDF 文件
- 自定义屏幕分辨率、时区和语言环境
- 浏览器启动标志和[更多选项](https://testingbot.com/support/web-automate/puppeteer/options)

 语言与跑步者 
## 测试框架的整合

TestingBot集成了Puppeteer和支持Puppeteer的流行测试框架，如：。

- ### [Node.js](https://testingbot.com/support/web-automate/puppeteer/capabilities)

  - [Quickstart](https://testingbot.com/support/web-automate/puppeteer)
  - [Capabilities](https://testingbot.com/support/web-automate/puppeteer/capabilities)
  - [Browser flags](https://testingbot.com/support/web-automate/puppeteer/options)
  - [Test results](https://testingbot.com/support/web-automate/puppeteer/test-results)

- ### [Jest](https://testingbot.com/support/web-automate/puppeteer/jest)

  - [Jest with Puppeteer](https://testingbot.com/support/web-automate/puppeteer/jest)

- ### [WebDriverIO](https://testingbot.com/support/web-automate/puppeteer/webdriverio)

  - [WebDriverIO + Puppeteer](https://testingbot.com/support/web-automate/puppeteer/webdriverio)

- ### [CodeceptJS](https://testingbot.com/support/web-automate/puppeteer/codeceptjs)

  - [CodeceptJS setup](https://testingbot.com/support/web-automate/puppeteer/codeceptjs)

- ### [Python · PyTest](https://testingbot.com/support/web-automate/puppeteer/pytest)

  - [PyTest with Pyppeteer](https://testingbot.com/support/web-automate/puppeteer/pytest)

- ### [Go · chromedp](https://testingbot.com/support/web-automate/puppeteer/chromedp)

  - [chromedp setup](https://testingbot.com/support/web-automate/puppeteer/chromedp)

使用[Puppeteer Recorder](https://testingbot.com/support/web-automate/puppeteer/recorder) 记录 Puppeteer 脚本。在 TestingBot 的浏览器网格上运行录制的 Puppeteer 脚本，以实现最大的覆盖率。

 大规模并行 
## 将 Puppeteer 套件的使用时间从数小时缩短到数分钟

在单用途虚拟机上并行运行数百个 Puppeteer 会话。无论使用无头模式还是有头模式，使用相同的脚本，运行时间却大大缩短。

- 最多可同时进行 100 个 Puppeteer 会话
- 训练课几秒钟内即可开始，无需热身。
- 无头模式或有头模式，每次会话均可切换

[阅读更多](https://testingbot.com/support/web-automate/puppeteer/puppeteer-parallel-testing)

 ![将 Puppeteer 套件的使用时间从数小时缩短到数分钟](https://zh.testingbot.com/assets/features/selenium/parallel-0229d698e59a8a6b92fe50344a08634624f018331ecf8a849ef83cfb35e635a5.png)

Live exit nodes
10+ countries

美国

英国

德国

法国

西班牙

比利时

澳大利亚

中国

日本

 地理位置测试 
## 来自 10 多个国家的 Puppeteer 测试脚本

从世界各地的真实出口节点运行 Puppeteer 脚本。验证来自美国、英国、德国、法国、西班牙、比利时、澳大利亚、中国、日本等地 **的地理定位** 、 **地理屏蔽** 和 **本地化功能** 。

 安全的基础设施 
## 真正的机器。一次性使用。零泄漏。

每个 Puppeteer 会话都在真实操作系统上一个全新的、一次性使用的虚拟机中运行。脚本结束后，虚拟机立即被销毁：没有任何数据会被重用，也不会跨客户端泄露。

符合 SOC 2 标准，符合 GDPR 标准，支持欧盟数据驻留、SAML SSO 和审计日志，可供企业团队使用。

- 一次性虚拟机，每次会话结束后都会被清除
- 符合 GDPR 标准，可提供欧盟数据驻留服务
- SAML SSO、审计日志和 SCIM 配置

[访问 TestingBot 信任中心](https://trust.testingbot.com/)

1. 1

脚本连接到`cloud.testingbot.com`

只需几秒钟，即可为您创建一个全新的虚拟机，专供您使用。

2. 2

Puppeteer 驱动着真正的 Chrome 或 Edge 浏览器。

真正的 Windows、macOS 或 Linux 系统，从未模拟，从未共享。

3. 3

脚本结束后，虚拟机立即被销毁。

Cookies、文件、浏览器状态，全部清除。所有数据都不会被重复使用。

 持续集成 
## 几分钟内即可将 Puppeteer 集成到您的 CI/CD 系统中

TestingBot 可与所有主流 CI/CD 工具集成。它会在每次提交时触发 Puppeteer，并将视频和日志流式传输回您的构建仪表板。

 ![Jenkins](https://zh.testingbot.com/assets/integrations/jenkins-e586a1c4af833e4c8d38d7b392a4e84bd193f30cae9cf8c9f198a58ec943a1ff.webp)

### [Jenkins](https://testingbot.com/support/integrations/ci-cd/jenkins)

 ![Bamboo](https://zh.testingbot.com/assets/integrations/bamboo-c8fe09a3cb0b74d6055e3aa6607d77720bfe29ff487b8e3cf825138adf634346.svg)

### [Bamboo](https://testingbot.com/support/integrations/ci-cd/bamboo)

 ![TeamCity](https://zh.testingbot.com/assets/integrations/teamcity-7e75cdb835903a4983ad276c41d95e569ceac5be486e96ec1f955029ce5bb319.svg)

### [TeamCity](https://testingbot.com/support/integrations/ci-cd/teamcity)

 ![CircleCI](https://zh.testingbot.com/assets/integrations/circleci-ede029654ff39b60342e4a5bba8fc9a3a49305cc38bda215b7cf8d07e85e0543.webp)

### [CircleCI](https://testingbot.com/support/integrations/ci-cd/circleci)

 ![GitLab CI](https://zh.testingbot.com/assets/integrations/gitlab-e4c0b6db07d07bc0a400f5606e258f4dc8a51b778e97bbfa51d1d531f3cb049a.webp)

### [GitLab CI](https://testingbot.com/support/integrations/ci-cd/gitlab)

 ![GitHub](https://zh.testingbot.com/assets/integrations/github-actions-8436242ad9e15381f84f1a98a10dddce15611087f121d6305782e211942b7842.webp)

### [GitHub](https://testingbot.com/support/integrations/ci-cd/github-actions)

 Secure Tunnel 
## 安全地测试内部和测试环境应用程序

使用我们的[安全隧道](https://testingbot.com/support/tunnel)，针对受防火墙保护的测试站点、内部仪表板或仍在本地主机上的应用程序运行 Puppeteer 脚本。

端到端加密，无需入站防火墙规则，开箱即用，适用于主流 CI 提供商。

 ![TestingBot secure tunnel for Puppeteer](https://zh.testingbot.com/assets/features/tunnel-diagram-poster-8c25e19e6fe4f7276a46a96b31a0ad0e07bb4f5bf98dc192d2b70897cfbb1a26.png)

[阅读更多](https://zh.testingbot.com/support/tunnel)

常问问题
## TestingBot 上的 Puppeteer — 常见问题解答

为什么要在 TestingBot 上运行 Puppeteer 而不是在本地运行？

本地性能受限于笔记本电脑或 CI 运行器。TestingBot 可在真实的 Windows、macOS 和 Linux 机器上，通过真实的 Chrome 和 Edge 浏览器，支持多达 100 个并行 Puppeteer 会话，并自动收集高清视频和控制台日志。

支持哪些 Puppeteer 版本？

TestingBot 支持所有受支持的 Puppeteer 版本。您可以使用功能为每个测试指定特定的 Puppeteer 版本。

我可以并行运行 Puppeteer 测试吗？

是的。TestingBot 的计划包括最多 100 个并行 Puppeteer 会话。每个会话都在其独立的单次使用虚拟机中运行，因此脚本之间不会相互干扰。

我可以将 Puppeteer 与 Jest、WebDriverIO 或 CodeceptJS 一起使用吗？

是的。我们有专门针对[Jest](https://testingbot.com/support/web-automate/puppeteer/jest) 、 [WebDriverIO](https://testingbot.com/support/web-automate/puppeteer/webdriverio)和[CodeceptJS 的](https://testingbot.com/support/web-automate/puppeteer/codeceptjs)指南，还有针对 Python（通过[PyTest）](https://testingbot.com/support/web-automate/puppeteer/pytest)和 Go（通过[chromedp）的](https://testingbot.com/support/web-automate/puppeteer/chromedp)指南。

Puppeteer 与 Selenium 和 Playwright 有何不同？

Puppeteer 优先支持 Chrome 和 Node，其 API 比 Selenium 更简洁、更快速，但功能范围比 Playwright 更窄。如果您只需要 Chrome/Edge 浏览器，并且希望以最少的配置实现速度、屏幕截图、PDF 生成和网络控制，那么 Puppeteer 是您的理想之选。TestingBot 在同一平台上同时支持这三种浏览器。

我可以不编写代码就录制 Puppeteer 脚本吗？

是的，使用[Puppeteer Recorder](https://testingbot.com/support/web-automate/puppeteer/recorder)捕获点击、输入和断言，然后在 TestingBot 网格上运行生成的脚本。

我可以测试内部站点或测试站点吗？

是的，安装我们的[安全隧道](https://testingbot.com/support/tunnel)后，您的 Puppeteer 脚本就可以访问测试环境、本地主机或防火墙后的任何其他内容。

Puppeteer云平台是否符合GDPR/SOC 2标准？

TestingBot 符合 GDPR 法规，拥有欧盟数据驻留权，并通过了 ISO 27001 标准认证和 STAR 1 级认证。我们为企业版套餐提供 SAML 单点登录 (SSO)、敏感信息安全管理 (SCIM) 和审计日志功能。

## 准备好开始Puppeteer测试了吗？

要开始使用，请看我们的[Puppeteer测试](https://testingbot.comweb-automate/)文档。

[开始免费试用](https://zh.testingbot.com/users/sign_up)

您可能喜欢的资源

[![Automated Testing with Puppeteer](https://zh.testingbot.com/assets/resources/articles/11-416015eb394d928299663409dccd67993b0a664f4b3ff456803fefc6bf1f325a.webp)](https://testingbot.com/resources/articles/automated-testing-with-puppeteer)
### [Automated Testing with Puppeteer](https://testingbot.com/resources/articles/automated-testing-with-puppeteer)

Puppeteer combined with a test framework provides a great way to run automated browser tests. Follow this guide for more information.

[阅读更多](https://testingbot.com/resources/articles/automated-testing-with-puppeteer)

[![Puppeteer Testing in the Cloud](https://zh.testingbot.com/assets/blog/2021/puppeteer.webp)](https://testingbot.com/blog/puppeteer-cloud-testing)
### [Puppeteer Testing in the Cloud](https://testingbot.com/blog/puppeteer-cloud-testing)

Start running Puppeteer tests in the cloud with TestingBot.

[阅读更多](https://testingbot.com/blog/puppeteer-cloud-testing)
