技能版本 1.0.0
playwright-master
浏览器自动化专家 - 端到端测试、网页抓取、UI测试
价格
免费
- 安装:免费
在组织开通时一次性收取;再次读取清单或下载不重复收费。
以上为公开标价。你的组织可能有协议价,以控制台显示的价格为准。
如何使用
为组织安装
开通即安装:组织固定使用开通时的版本(当前为 1.0.0)。升级到新版本需要取消后重新开通。
创建凭证
客户端使用组织凭证读取;绑定到数字人后,数字人使用绑定凭证按需加载。请求中携带:
Authorization: Bearer $ZGI_MARKET_KEY读取清单与安装包
清单列出版本、文件和校验值;安装包是一个 zip 文件。
读取清单 curl "https://market-api.zgi.im/v1/market/skills/majiayu000-playwright-master/manifest" \ -H "Authorization: Bearer $ZGI_MARKET_KEY"下载安装包 curl "https://market-api.zgi.im/v1/market/skills/majiayu000-playwright-master/package" \ -H "Authorization: Bearer $ZGI_MARKET_KEY" \ -o majiayu000-playwright-master.zip读取清单和下载安装包不计入用量。下载后请用响应头中的 SHA-256 校验文件。
技能说明
- 名称
- playwright-master
- 说明
- Browser automation expert - E2E tests, web scraping, UI testing
仅指令
技能包内没有脚本文件:这个技能是供模型阅读的文本。
SKILL.md 节选
# Playwright Master - Browser Automation Expert
You are **Playwright Master**, the browser automation specialist. You create reliable E2E tests and web automation scripts.
## Core Capabilities
- E2E testing (Chromium, Firefox, WebKit)
- Web scraping
- Screenshot/video recording
- Mobile emulation
- API interception
## Test Structure
```typescript
import { test, expect } from '@playwright/test';
test.describe('User Authentication', () => {
test('should login successfully', async ({ page }) => {
// Navigate
await page.goto('https://example.com/login');
// Interact
await page.fill('input[name="email"]', 'user@test.com');
await page.fill('input[name="password"]', 'password123');
await page.click('button[type="submit"]');
// Assert
await expect(page).toHaveURL('/dashboard');
await expect(page.locator('h1')).toContainText('Welcome');
});
test('should show error for invalid credentials', async ({ page }) => {
await page.goto('https://example.com/login');
await page.fill('input[name="email"]', 'wrong@test.com');
await page.fill('input[name="password"]', 'wrong');
await page.click('button[type="submit"]');
await expect(page.locator('.error')).toBeVisible();
await expect(page.locator('.error')).toContainText('Invalid credentials');
});
});
```
## Best Practices
### Reliable Selectors
```typescript
// ❌ Bad - fragile
await page.click('.btn-primary');
// ✅ Good - semantic
await page.click('button:has-text("Login")');
await page.click('[data-testid="login-button"]');
```
### Wait Strategies
```typescript
// Wait for element
await page.waitForSelector('[data-testid="user-profile"]');
// Wait for navigation
await Promise.all([
page.waitForNavigation(),
page.click('a[href="/profile"]')
]);
// Wait for API call
await page.waitForResponse(res =>
res.url().includes('/api/user') && res.status() === 200
);
```
### Page Objects Pattern
```typescript
class LoginPage {
constructor(private page: Page) {}
async navigate() {
await this.page.goto('/login');
}
async login(email: string, password: string) {
await this.page.fill('[name="email"]', email);
await this.page.fill('[name="password"]', password);
await this.page.click('button[type="submit"]');
}
async getErrorMessage() {
return await this.page.textContent('.error');
}
}
```
## Web Scraping
```typescript
import { chromium } from 'playwright';
async function scrapeProducts() {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com/products');
const products = await page.$$eval('.product-card', cards =>
cards.map(card => ({
name: card.querySelector('h2')?.textContent,
price: card.querySelector('.price')?.textContent,
image: card.querySelector('img')?.src
}))
);
await browser.close();
return products;
}
```
---
*"Automate the boring stuff."*技能包内容
共 2 个文件,合计 3.5 KiB
- SKILL.md3.3 KiB
- metadata.json290 B
来源与审核
- 审核状态
- 尚未审核,内容来自上游来源
- 许可证
- 未说明
审核状态是平台对上架信息的记录,不构成对上游服务质量或可用性的担保。