🛠️ 移行
既存のテストコードを、Cypress(サイプレス)
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Migrate from Cypress or Selenium to Playwright. Use when user mentions "cypress", "selenium", "migrate tests", "convert tests", "switch to playwright", "move from cypress", or "replace selenium".
🇯🇵 日本人クリエイター向け解説
既存のテストコードを、Cypress(サイプレス)
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o migrate.zip https://jpskill.com/download/4675.zip && unzip -o migrate.zip && rm migrate.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4675.zip -OutFile "$d\migrate.zip"; Expand-Archive "$d\migrate.zip" -DestinationPath $d -Force; ri "$d\migrate.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
migrate.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
migrateフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › Migrate を使って、最小構成のサンプルコードを示して
- › Migrate の主な使い方と注意点を教えて
- › Migrate を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] migrate
Playwrightへの移行
CypressまたはSeleniumからPlaywrightへのインタラクティブな移行を、ファイルごとの変換で行います。
入力
$ARGUMENTSは以下のいずれかです。
"from cypress"— Cypressテストスイートを移行します"from selenium"— Selenium/WebDriverテストを移行します- ファイルパス: 特定のテストファイルを変換します
- 空: ソースフレームワークを自動検出します
手順
1. ソースフレームワークの検出
Exploreサブエージェントを使用してスキャンします。
cypress/ディレクトリまたはcypress.config.ts→ Cypresspackage.jsonの依存関係にあるselenium、webdriver→ Seleniumseleniumインポートを含む.pyテストファイル → Selenium (Python)
2. 移行範囲の評価
ファイルを数え、分類します。
移行評価:
- 総テストファイル数: X
- Cypressカスタムコマンド: Y
- Cypressフィクスチャ: Z
- 推定作業量: [small|medium|large]
| サイズ | ファイル数 | アプローチ |
|---|---|---|
| 小 (1-10) | 順次変換 | 直接変換 |
| 中 (11-30) | 5つのグループにバッチ処理 | サブエージェントを使用 |
| 大 (31+) | /batchを使用 |
/batchによる並列変換 |
3. Playwrightのセットアップ (存在しない場合)
Playwrightが設定されていない場合は、まず/pw:initを実行します。
4. ファイルの変換
各ファイルに適切なマッピングを適用します。
Cypress → Playwright
完全なリファレンスについてはcypress-mapping.mdを読み込みます。
主な変換:
cy.visit(url) → page.goto(url)
cy.get(selector) → page.locator(selector) or page.getByRole(...)
cy.contains(text) → page.getByText(text)
cy.find(selector) → locator.locator(selector)
cy.click() → locator.click()
cy.type(text) → locator.fill(text)
cy.should('be.visible') → expect(locator).toBeVisible()
cy.should('have.text') → expect(locator).toHaveText(text)
cy.intercept() → page.route()
cy.wait('@alias') → page.waitForResponse()
cy.fixture() → JSON import or test data file
Cypressカスタムコマンド → Playwrightフィクスチャまたはヘルパー関数
Cypressプラグイン → Playwright設定またはフィクスチャ
before/beforeEach → test.beforeAll() / test.beforeEach()
Selenium → Playwright
完全なリファレンスについてはselenium-mapping.mdを読み込みます。
主な変換:
driver.get(url) → page.goto(url)
driver.findElement(By.id('x')) → page.locator('#x') or page.getByTestId('x')
driver.findElement(By.css('.x')) → page.locator('.x') or page.getByRole(...)
element.click() → locator.click()
element.sendKeys(text) → locator.fill(text)
element.getText() → locator.textContent()
WebDriverWait + ExpectedConditions → expect(locator).toBeVisible()
driver.switchTo().frame() → page.frameLocator()
Actions → locator.hover(), locator.dragTo()
5. ロケーターのアップグレード
変換中に、セレクターをPlaywrightのベストプラクティスにアップグレードします。
#id→getByTestId()またはgetByRole().class→getByRole()またはgetByText()[data-testid]→getByTestId()- XPath → ロールベースのロケーター
6. カスタムコマンド/ユーティリティの変換
- Cypressカスタムコマンド →
test.extend()を介したPlaywrightカスタムフィクスチャ - Seleniumページオブジェクト → Playwrightページオブジェクト (構造を維持し、APIを更新)
- 共有ヘルパー → TypeScriptユーティリティ関数
7. 変換された各ファイルの検証
各ファイルを変換した後:
npx playwright test <converted-file> --reporter=list
次のファイルに進む前に、コンパイルまたはランタイムエラーを修正します。
8. クリーンアップ
すべてのファイルが変換された後:
package.jsonからCypress/Seleniumの依存関係を削除します- 古い設定ファイル (
cypress.config.tsなど) を削除します - CIワークフローをPlaywrightを使用するように更新します
- READMEを新しいテストコマンドで更新します
何かを削除する前にユーザーに確認します。
出力
- 変換の概要: 変換されたファイル、移行されたテストの総数
- 自動変換できなかったテスト (手動での介入が必要)
- 更新されたCI設定
- テスト実行結果の変換前/変換後の比較
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Migrate to Playwright
Interactive migration from Cypress or Selenium to Playwright with file-by-file conversion.
Input
$ARGUMENTS can be:
"from cypress"— migrate Cypress test suite"from selenium"— migrate Selenium/WebDriver tests- A file path: convert a specific test file
- Empty: auto-detect source framework
Steps
1. Detect Source Framework
Use Explore subagent to scan:
cypress/directory orcypress.config.ts→ Cypressselenium,webdriverinpackage.jsondeps → Selenium.pytest files withseleniumimports → Selenium (Python)
2. Assess Migration Scope
Count files and categorize:
Migration Assessment:
- Total test files: X
- Cypress custom commands: Y
- Cypress fixtures: Z
- Estimated effort: [small|medium|large]
| Size | Files | Approach |
|---|---|---|
| Small (1-10) | Convert sequentially | Direct conversion |
| Medium (11-30) | Batch in groups of 5 | Use sub-agents |
| Large (31+) | Use /batch |
Parallel conversion with /batch |
3. Set Up Playwright (If Not Present)
Run /pw:init first if Playwright isn't configured.
4. Convert Files
For each file, apply the appropriate mapping:
Cypress → Playwright
Load cypress-mapping.md for complete reference.
Key translations:
cy.visit(url) → page.goto(url)
cy.get(selector) → page.locator(selector) or page.getByRole(...)
cy.contains(text) → page.getByText(text)
cy.find(selector) → locator.locator(selector)
cy.click() → locator.click()
cy.type(text) → locator.fill(text)
cy.should('be.visible') → expect(locator).toBeVisible()
cy.should('have.text') → expect(locator).toHaveText(text)
cy.intercept() → page.route()
cy.wait('@alias') → page.waitForResponse()
cy.fixture() → JSON import or test data file
Cypress custom commands → Playwright fixtures or helper functions
Cypress plugins → Playwright config or fixtures
before/beforeEach → test.beforeAll() / test.beforeEach()
Selenium → Playwright
Load selenium-mapping.md for complete reference.
Key translations:
driver.get(url) → page.goto(url)
driver.findElement(By.id('x')) → page.locator('#x') or page.getByTestId('x')
driver.findElement(By.css('.x')) → page.locator('.x') or page.getByRole(...)
element.click() → locator.click()
element.sendKeys(text) → locator.fill(text)
element.getText() → locator.textContent()
WebDriverWait + ExpectedConditions → expect(locator).toBeVisible()
driver.switchTo().frame() → page.frameLocator()
Actions → locator.hover(), locator.dragTo()
5. Upgrade Locators
During conversion, upgrade selectors to Playwright best practices:
#id→getByTestId()orgetByRole().class→getByRole()orgetByText()[data-testid]→getByTestId()- XPath → role-based locators
6. Convert Custom Commands / Utilities
- Cypress custom commands → Playwright custom fixtures via
test.extend() - Selenium page objects → Playwright page objects (keep structure, update API)
- Shared helpers → TypeScript utility functions
7. Verify Each Converted File
After converting each file:
npx playwright test <converted-file> --reporter=list
Fix any compilation or runtime errors before moving to the next file.
8. Clean Up
After all files are converted:
- Remove Cypress/Selenium dependencies from
package.json - Remove old config files (
cypress.config.ts, etc.) - Update CI workflow to use Playwright
- Update README with new test commands
Ask user before deleting anything.
Output
- Conversion summary: files converted, total tests migrated
- Any tests that couldn't be auto-converted (manual intervention needed)
- Updated CI config
- Before/after comparison of test run results