Token导航 LogoToken导航TokenDH.com
Pw MCP Cursor logo
浏览器工具stdio官方级别未说明来源级核验

Pw MCP Cursor

MCP Server

playwright

一个基于Playwright的端到端测试工具,支持TypeScript、页面对象模型和Allure报告,适用于跨浏览器测试和持续集成。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
TypeScriptCursor浏览器自动化Cursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

vkneze

提供方

vkneze

最后核验

2026/5/17 20:22

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx playwright install # Install browsers

详细介绍

剧作家测试自动化实践

![Playwright Tests](https://github.com/YOUR_USERNAME/YOUR_REPO_NAME/actions/workflows/playwright.yml) ![Nightly Tests](https://github.com/YOUR_USERNAME/YOUR_REPO_NAME/actions/workflows/nightly.yml)

E2E使用Playwright结合TypeScript、页面对象模型和Allure报告进行测试。

🎯 特性

  • ✅ 页面对象模型架构
  • ✅ TypeScript用于类型安全
  • ✅ 有历史/趋势的诱惑报告
  • ✅ GitHub操作带有浏览器缓存的CI/CD
  • ✅ 跨浏览器测试(Chromium、Firefox、WebKit)
  • ✅ 为不稳定的测试重试逻辑
  • ✅ 用于测试隔离的定制夹具

📋 安装

npm ci                      # Install dependencies
npx playwright install      # Install browsers

🧪 运行测试

# Run all tests
npx playwright test

# Run specific file
npx playwright test homepage.spec.ts

# Run by tag
npx playwright test --grep '@smoke'

# Run by title
npx playwright test -g "should login successfully"

# Run last failed
npx playwright test --last-failed

# Run headed/debug mode
npx playwright test --headed
npx playwright test --debug

# Run specific browser
npx playwright test --project=chromium

📋 列出测试

npx playwright test --list                # All tests
npx playwright test --list --grep '@smoke' # Filtered by tag

📊 报告

剧作家HTML报告

npx playwright show-report

诱惑报告

🌐 推荐:在GitHub页面上查看

每次CI运行后都会自动部署报告:

  • 网址: https://.github.io//
  • 设置: 回购设置→ 页面→ 来源: gh页面 分支
  • 优点: 始终保持最新状态,包括趋势,无需本地设置

本地生成:

npm run allure:serve              # Generate and open (auto-starts server)
npm run allure:generate           # Generate only
npm run allure:open               # Open existing report
npm run allure:clean              # Clean old reports

📊 趋势: 运行测试2-3次以上,查看趋势图(持续时间、重试次数、历史记录)。

注: 如果从GitHub Actions下载工件,请不要打开 index.html 直接。通过HTTP提供服务: cd allure-report && npx -y serve -p 8080 . → http://localhost:8080

🔄 GitHub操作

测试在以下情况下自动运行:

  • 推到 main, feature/**, fix/** 分支
  • 将请求拉到 main
  • 手动触发

浏览器缓存已启用 -第一次运行速度较慢,随后每个浏览器的运行速度要快60秒左右。

🏗️ 项目结构

├── tests/              # Test specs
├── pages/              # Page Objects
├── actions/            # Reusable actions
├── helpers/            # Utilities
├── data/               # Test data
├── constants/          # Selectors, configs
├── fixtures/           # Custom fixtures
├── .cursor/            # Cursor AI rules & commands
│   ├── rules/          # Workspace rules
│   └── commands/       # Custom commands
└── .github/            # GitHub configuration
    └── workflows/      # CI/CD workflows

📝 写作测试

test('example', async ({ homePage, cartPage }) => {
  await homePage.goto();
  await homePage.addFirstNProductsToCart(2);
  await cartPage.assertCartItemsExactCount(2);
});

🔧 版本管理

# Check version
npx playwright --version
npm ls @playwright/test

# Upgrade
npm install playwright@latest
npm install playwright@1.50.1    # Specific version

# Fix multiple versions
rm -rf node_modules package-lock.json
npm install

重要提示: 更新 .github/workflows/playwright.yml 与剧作家的版本相匹配。

🧪 测试与整理

npx tsc -p tsconfig.json         # Check TypeScript
npx eslint .                     # Lint
npx eslint . --fix               # Lint and fix

💡 最佳实践

  • 标签测试: @smoke, @sanity, @flaky
  • 使用 .fixme() 用于带注释的失败测试
  • 在页面构造函数中保留定位器
  • 将测试数据集中到 data/
  • 遵循安排→ Act → 断言模式

📚 文档

目录标签

目录标签

TypeScriptCursor浏览器自动化端到端测试本地部署跨浏览器测试持续集成Allure报告

支持客户端

Cursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

playwright

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosession部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP