新闻详情

新闻详情

首页 / 资讯中心 / 详情

Playwright 自动化测试 - 初始化 Playwright 项目的过程

发布时间:2026/11/6 16:28:51来源:尧图网络
Playwright 自动化测试 - 初始化 Playwright 项目的过程
初始化 Playwright 项目的过程1、演示运行npm init playwrightlatest初始化 Playwright 项目的过程Getting started with writing end-to-end tests with Playwright: Initializing project in . √ Do you want to use TypeScript or JavaScript? · TypeScript √ Where to put your end-to-end tests? · tests √ Add a GitHub Actions workflow? (Y/n) · true √ Install Playwright browsers (can be done manually via npx playwright install)? (Y/n) · true Initializing NPM project (npm init -y)… Wrote to D:\WEB\PlaywrightTest\package.json: { name: playwrighttest, version: 1.0.0, description: , main: index.js, scripts: { test: echo \Error: no test specified\ exit 1 }, keywords: [], author: , license: ISC } Installing Playwright Test (npm install --save-dev playwright/test)… added 3 packages, and audited 4 packages in 5s found 0 vulnerabilities Installing Types (npm install --save-dev types/node)… added 2 packages, and audited 6 packages in 2s found 0 vulnerabilities Writing playwright.config.ts. Writing .github\workflows\playwright.yml. Writing tests\example.spec.ts. Writing package.json. Downloading browsers (npx playwright install)… Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: Request to https://storage.googleapis.com/chrome-for-testing-public/153.0.8010.12/win64/chrome-win64.zip timed out after 30000ms at ClientRequest.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:8793:15) at Object.onceWrapper (node:events:633:28) at ClientRequest.emit (node:events:519:28) at TLSSocket.emitRequestTimeout (node:_http_client:931:9) at Object.onceWrapper (node:events:633:28) at TLSSocket.emit (node:events:531:35) at Socket._onTimeout (node:net:605:8) at listOnTimeout (node:internal/timers:585:17) at process.processTimers (node:internal/timers:521:7) Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: Request to https://storage.googleapis.com/chrome-for-testing-public/153.0.8010.12/win64/chrome-win64.zip timed out after 30000ms at ClientRequest.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:8793:15) at Object.onceWrapper (node:events:633:28) at ClientRequest.emit (node:events:519:28) at TLSSocket.emitRequestTimeout (node:_http_client:931:9) at Object.onceWrapper (node:events:633:28) at TLSSocket.emit (node:events:531:35) at Socket._onTimeout (node:net:605:8) at listOnTimeout (node:internal/timers:585:17) at process.processTimers (node:internal/timers:521:7) Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Failed to install browsers Error: Failed to download Chrome for Testing 153.0.8010.12 (playwright chromium v1243), caused by Error: Download failure, code1 at ChildProcess.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:32428:32) at ChildProcess.emit (node:events:519:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12) Error: Command failed: npx playwright install at genericNodeError (node:internal/errors:983:15) at wrappedFn (node:internal/errors:537:14) at checkExecSyncError (node:child_process:916:11) at execSync (node:child_process:988:15) at executeCommands (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8272:39) at Generator.run (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8356:5) at process.processTicksAndRejections (node:internal/process/task_queues:103:5) at async _Command.anonymous (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8661:3) at async _Command.parseAsync (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:2148:9) { status: 1, signal: null, output: [ null, null, null ], pid: 21668, stdout: null, stderr: null }2、解读1初始化配置项Getting started with writing end-to-end tests with Playwright: Initializing project in . √ Do you want to use TypeScript or JavaScript? · TypeScript √ Where to put your end-to-end tests? · tests √ Add a GitHub Actions workflow? (Y/n) · true √ Install Playwright browsers (can be done manually via npx playwright install)? (Y/n) · true指令执行后Playwright 的脚手架向开发者询问了几个配置项配置项当前配置语言TypeScript测试目录tests添加 GitHub Actions 工作流true安装 Playwright 浏览器true2初始化骨架和依赖Initializing NPM project (npm init -y)… Wrote to D:\WEB\PlaywrightTest\package.json: { name: playwrighttest, version: 1.0.0, description: , main: index.js, scripts: { test: echo \Error: no test specified\ exit 1 }, keywords: [], author: , license: ISC }运行npm init -y生成package.json文件。此时scripts.test还是默认的报错占位Installing Playwright Test (npm install --save-dev playwright/test)… added 3 packages, and audited 4 packages in 5s found 0 vulnerabilities Installing Types (npm install --save-dev types/node)… added 2 packages, and audited 6 packages in 2s found 0 vulnerabilities安装playwright/test3 个包和types/node2 个包Writing playwright.config.ts. Writing .github\workflows\playwright.yml. Writing tests\example.spec.ts. Writing package.json.写入以下文件playwright.config.ts 文件这是配置文件 .github\workflows\playwright.yml 文件这是 CI 工作流 tests\example.spec.ts 文件这是示例测试 更新后的 package.json 文件3下载浏览器Downloading browsers (npx playwright install)… Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: Request to https://storage.googleapis.com/chrome-for-testing-public/153.0.8010.12/win64/chrome-win64.zip timed out after 30000ms at ClientRequest.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:8793:15) at Object.onceWrapper (node:events:633:28) at ClientRequest.emit (node:events:519:28) at TLSSocket.emitRequestTimeout (node:_http_client:931:9) at Object.onceWrapper (node:events:633:28) at TLSSocket.emit (node:events:531:35) at Socket._onTimeout (node:net:605:8) at listOnTimeout (node:internal/timers:585:17) at process.processTimers (node:internal/timers:521:7) Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: Request to https://storage.googleapis.com/chrome-for-testing-public/153.0.8010.12/win64/chrome-win64.zip timed out after 30000ms at ClientRequest.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:8793:15) at Object.onceWrapper (node:events:633:28) at ClientRequest.emit (node:events:519:28) at TLSSocket.emitRequestTimeout (node:_http_client:931:9) at Object.onceWrapper (node:events:633:28) at TLSSocket.emit (node:events:531:35) at Socket._onTimeout (node:net:605:8) at listOnTimeout (node:internal/timers:585:17) at process.processTimers (node:internal/timers:521:7) Downloading Chrome for Testing 153.0.8010.12 (playwright chromium v1243) from https://cdn.playwright.dev/builds/cft/153.0.8010.12/win64/chrome-win64.zip Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) { errno: -4077, code: ECONNRESET, syscall: read } Failed to install browsers Error: Failed to download Chrome for Testing 153.0.8010.12 (playwright chromium v1243), caused by Error: Download failure, code1 at ChildProcess.anonymous (D:\WEB\PlaywrightTest\node_modules\playwright-core\lib\coreBundle.js:32428:32) at ChildProcess.emit (node:events:519:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12) Error: Command failed: npx playwright install at genericNodeError (node:internal/errors:983:15) at wrappedFn (node:internal/errors:537:14) at checkExecSyncError (node:child_process:916:11) at execSync (node:child_process:988:15) at executeCommands (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8272:39) at Generator.run (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8356:5) at process.processTicksAndRejections (node:internal/process/task_queues:103:5) at async _Command.anonymous (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:8661:3) at async _Command.parseAsync (C:\Users\32123\AppData\Local\npm-cache\_npx\d352e76cc6b4974c\node_modules\create-playwright\lib\index.js:2148:9) { status: 1, signal: null, output: [ null, null, null ], pid: 21668, stdout: null, stderr: null }运行npx playwright install下载浏览器3、关于下载浏览器的问题1问题原因下载 Chromium 时连续报了 5 次错最终失败。错误类型如下Error: read ECONNRESET连接被对方重置通常是网络中断、被防火墙 / 代理拦截、CDN 连接不稳定Request to https://storage.googleapis.com/... timed out after 30000ms网络无法稳定访问2处理策略Playwright 可以使用本机已装浏览器免下载。在playwright.config.ts文件添加如下配置use:{channel:chrome,// 或 msedge},
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

【外设】之大彩串口显示屏 2026/11/6 6:37:16

【外设】之大彩串口显示屏

大彩串口屏初步使用 1 .官网下载 STM32 屏幕 GUI 设计资料 http://www.gz-dc.com/category/typeid/4112 找到 STM32 Keil 工程,移植相关代码因项目而异进行移植,由于项目简单,本人只对用到的指令接口进行修改。 比如:注意事项&…

阅读更多 →
无法下载Windows系统iso文件 2026/11/6 0:32:51

无法下载Windows系统iso文件

当我遇到这个问题的时候,我打开了一个网站: 登录 然后我打算下载的时候: 突然那个官方的连接就可以下载了:

阅读更多 →
【清华代码熊】DeepSeek V4.1 Flash 后训练详解 2026/11/6 1:10:54

【清华代码熊】DeepSeek V4.1 Flash 后训练详解

📌 上期解析了 DeepSeek V4.1 Flash 模型架构改进,本期解析 DeepSeek V4.1 Flash 预训练/后训练技术: 🌟 预训练:45T 文本 多模态混合语料、直接训练 sparse attention(取消 DeepSeek V4 的 dense 冷启动&…

阅读更多 →
Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ... 2026/11/5 15:28:55

Shuffle-R1: Efficient RL framework for Multimodal Large Language Models via Data-centric Dynamic ...

文章主要内容和创新点 主要内容 本文聚焦于多模态大语言模型(MLLM)强化学习(RL)训练中的效率问题,提出了一个名为Shuffle-R1的框架。研究发现,当前RL训练存在两个关键缺陷: 优势值坍缩(Advantage Collapsing):批次中大多数优势值集中在零附近,导致有效梯度信号被淹…

阅读更多 →
PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction 2026/11/6 14:29:05

PRvL: Quantifying the Capabilities and Risks of Large Language Models for PII Redaction

一、文章主要内容总结 本文聚焦于利用大型语言模型(LLMs)实现个人身份信息(PII)脱敏的研究,旨在解决传统脱敏方法(如基于规则的系统、领域特定命名实体识别(NER)模型)泛化能力差、跨格式/跨语境适应性弱的问题。 研究通过全面评估多种LLM架构(包括密集型LLM(D-LLM…

阅读更多 →
LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model 2026/11/6 14:29:07

LLaVA-RE: Binary Image-Text Relevancy Evaluation with Multimodal Large Language Model

文章主要内容和创新点 主要内容 本文聚焦于二进制图像-文本相关性评估任务(判断图像与文本“相关”或“不相关”),针对该任务中文本格式多样、相关性定义随场景变化等挑战,提出了基于多模态大语言模型(MLLM)的解决方案LLaVA-RE。 模型设计:LLaVA-RE基于LLaVA 1.5架构,…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉