Phoenix Playwright Testsのロゴ

Phoenix Playwright Tests

組織人気
Arize-ai
phoenix-playwright-tests

Phoenix AIオブザーバビリティプラットフォーム向けのPlaywright E2Eテストを作成します。Playwrightテストの作成、更新、デバッグのほか、UI機能のテスト、E2Eテストの作成、Phoenixでのブラウザー操作の自動化についてユーザーから依頼されたときに使用します。

Add to TypingMind

概要

公開者Arize-ai
リポジトリphoenix
スキル名phoenix-playwright-tests
スター
11.8K
フォーク
1.2K
同梱ファイル
2
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    Arize-aiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Phoenix Playwright Tests」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Arize-ai/phoenix/tree/main/.agents/skills/phoenix-playwright-tests
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Arize-ai/phoenix.git /tmp/phoenix
mkdir -p .claude/skills
cp -r /tmp/phoenix/.agents/skills/phoenix-playwright-tests .claude/skills/phoenix-playwright-tests
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでPhoenix Playwright Testsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にPhoenix Playwright Testsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Phoenix Playwright Testsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Phoenix Playwright Test Writing

Write end-to-end tests for Phoenix using Playwright. Tests live in js/app/tests/ and follow established patterns.

Timeout Policy

  • Do not pass timeout args in test code under js/app/tests.
  • Tune timing centrally in js/app/playwright.config.ts (global timeout, expect.timeout, use.navigationTimeout, and webServer.timeout).

Quick Start

typescript
import { expect, test } from "@playwright/test";
import { randomUUID } from "crypto";

test.describe("Feature Name", () => {
  test.beforeEach(async ({ page }) => {
    await page.goto(`/login`);
    await page.getByLabel("Email").fill("admin@localhost");
    await page.getByLabel("Password").fill("admin123");
    await page.getByRole("button", { name: "Log In", exact: true }).click();
    await page.waitForURL("**/projects");
  });

  test("can do something", async ({ page }) => {
    // Test implementation
  });
});

Test Credentials

UserEmailPasswordRole
Adminadmin@localhostadmin123admin
Membermember@localhost.commember123member
Viewerviewer@localhost.comviewer123viewer

Selector Patterns (Priority Order)

  1. Role selectors (most robust):

    typescript
    page.getByRole("button", { name: "Save" });
    page.getByRole("link", { name: "Datasets" });
    page.getByRole("tab", { name: /Evaluators/i });
    page.getByRole("menuitem", { name: "Edit" });
    page.getByRole("cell", { name: "my-item" });
    page.getByRole("heading", { name: "Title" });
    page.getByRole("dialog");
    page.getByRole("textbox", { name: "Name" });
    page.getByRole("combobox", { name: /mapping/i });
  2. Label selectors:

    typescript
    page.getByLabel("Email");
    page.getByLabel("Dataset Name");
    page.getByLabel("Description");
  3. Text selectors:

    typescript
    page.getByText("No evaluators added");
    page.getByPlaceholder("Search...");
  4. Test IDs (when available):

    typescript
    page.getByTestId("create-dataset-button");
    // element with state — select the stable id, filter on the data attribute
    page.locator('[data-testid="llm-evaluator-form-submit-button"][data-mode="create"]');

    data-testids are scoped, fully spelled out (...-button, never ...-btn), and constant regardless of state — state is exposed via a sibling data-* attribute (data-mode, data-state, …), so never key a getByTestId off a value that only exists in one mode. If you need a data-testid that doesn't exist yet, add it following references/test-ids.md in the phoenix-frontend skill (pattern: <scope>-<subject>-<role>).

  5. CSS locators (last resort):

    typescript
    page.locator('button:has-text("Save")');

Common UI Patterns

Dropdown Menus

typescript
// Click button to open dropdown
await page.getByRole("button", { name: "New Dataset" }).click();
// Select menu item
await page.getByRole("menuitem", { name: "New Dataset" }).click();

Nested Menus (Submenus)

typescript
// Open menu, hover over submenu trigger, click submenu item
await page.getByRole("button", { name: "Add evaluator" }).click();
await page
  .getByRole("menuitem", { name: "Use LLM evaluator template" })
  .hover();
await page.getByRole("menuitem", { name: /correctness/i }).click();

// IMPORTANT: Always use getByRole("menuitem") for submenu items, not getByText()
// Playwright's auto-waiting handles the submenu appearance timing
// ❌ BAD - flaky in CI:
// await page.getByText("ExactMatch").first().click();
// ✅ GOOD - reliable:
// await page.getByRole("menuitem", { name: /ExactMatch/i }).click();

Dialogs/Modals

typescript
// Wait for dialog
await expect(page.getByRole("dialog")).toBeVisible();
// Fill form in dialog
await page.getByLabel("Name").fill("test-name");
// Submit
await page.getByRole("button", { name: "Create" }).click();
// Wait for close
await expect(page.getByRole("dialog")).not.toBeVisible();

Tables with Row Actions

typescript
// Find row by cell content
const row = page.getByRole("row").filter({
  has: page.getByRole("cell", { name: "item-name" }),
});
// Click action button in row (usually last button)
await row.getByRole("button").last().click();
// Select action from menu
await page.getByRole("menuitem", { name: "Edit" }).click();

Tabs

typescript
await page.getByRole("tab", { name: /Evaluators/i }).click();
await page.waitForURL("**/evaluators");
await expect(page.getByRole("tab", { name: /Evaluators/i })).toHaveAttribute(
  "aria-selected",
  "true",
);

Form Inputs in Sections

typescript
// When multiple textboxes exist, scope to section
const systemSection = page.locator('button:has-text("System")');
const systemTextbox = systemSection
  .locator("..")
  .locator("..")
  .getByRole("textbox");
await systemTextbox.fill("content");

Serial Tests (Shared State)

Use test.describe.serial when tests depend on each other:

typescript
test.describe.serial("Workflow", () => {
  const itemName = `item-${randomUUID()}`;

  test("step 1: create item", async ({ page }) => {
    // Creates itemName
  });

  test("step 2: edit item", async ({ page }) => {
    // Uses itemName from previous test
  });

  test("step 3: verify edits", async ({ page }) => {
    // Verifies itemName was edited
  });
});

Assertions

typescript
// Visibility
await expect(element).toBeVisible();
await expect(element).not.toBeVisible();

// Text content
await expect(element).toHaveText("expected");
await expect(element).toContainText("partial");

// Attributes
await expect(element).toHaveAttribute("aria-selected", "true");

// Input values
await expect(input).toHaveValue("expected value");

// URL
await page.waitForURL("**/datasets/**/examples");

Navigation Patterns

typescript
// Direct navigation
await page.goto("/datasets");
await page.waitForURL("**/datasets");

// Click navigation
await page.getByRole("link", { name: "Datasets" }).click();
await page.waitForURL("**/datasets");

// Extract ID from URL
const url = page.url();
const match = url.match(/datasets\/([^/]+)/);
const datasetId = match ? match[1] : "";

// Navigate with query params
await page.goto(`/playground?datasetId=${datasetId}`);

Running Tests

Before running Playwright tests, build the app so E2E runs against the latest frontend changes:

bash
pnpm run build
bash
# Run specific test file
pnpm exec playwright test tests/server-evaluators.spec.ts --project=chromium

# Run with UI mode
pnpm exec playwright test --ui

# Run specific test by name
pnpm exec playwright test -g "can create"

# Debug mode
pnpm exec playwright test --debug

Avoiding Interactive Report Server

By default, Playwright serves an HTML report after tests finish and waits for Ctrl+C, which can cause command timeouts. Use these options to avoid this:

bash
# Use list reporter (no interactive server)
pnpm exec playwright test tests/example.spec.ts --project=chromium --reporter=list

# Use dot reporter for minimal output
pnpm exec playwright test tests/example.spec.ts --project=chromium --reporter=dot

# Set CI mode to disable interactive features
CI=1 pnpm exec playwright test tests/example.spec.ts --project=chromium

Recommended for automation: Always use --reporter=list or CI=1 when running tests programmatically to ensure the command exits cleanly after tests complete.

Phoenix-Specific Pages

PageURL PatternKey Elements
Datasets/datasetsTable, "New Dataset" button
Dataset Detail/datasets/{id}/examplesTabs (Experiments, Examples, Evaluators, Versions)
Dataset Evaluators/datasets/{id}/evaluators"Add evaluator" button, evaluators table
Playground/playgroundPrompts section, Experiment section
Playground + Dataset/playground?datasetId={id}Dataset selector, Evaluators button
Prompts/prompts"New Prompt" button, prompts table
Settings/settings/general"Add User" button, users table

UI Exploration

When selectors are unclear, use the available browser tooling to explore the Phoenix UI at http://localhost:6006/datasets. Inspect accessible roles and names, interact with the target elements, and inspect the page again after navigation or DOM changes.

Use the observed roles and names to choose Playwright selectors:

UI elementPlaywright selector
Button "Save"page.getByRole("button", { name: "Save" })
Link "Datasets"page.getByRole("link", { name: "Datasets" })
Textbox "Name"page.getByRole("textbox", { name: "Name" })
Menu item "Edit"page.getByRole("menuitem", { name: "Edit" })
Tab "Evaluators 0"page.getByRole("tab", { name: /Evaluators/i })

File Naming

  • Feature tests: {feature-name}.spec.ts
  • Access control: {role}-access.spec.ts
  • Rate limiting: {feature}.rate-limit.spec.ts (runs last)

Common Gotchas

  1. Dialog not closing: Wait for a deterministic post-action signal (e.g., dialog hidden + success row visible)
  2. Multiple elements: Use .first(), .last(), or .nth(n)
  3. Dynamic content: Use regex in name: { name: /pattern/i }
  4. Flaky waits: Prefer waitForURL over waitForTimeout
  5. Menu not appearing: Wait for specific menu state/element visibility

Debugging Flaky Tests

Critical Lessons Learned

  1. Don't assume parallelism is the problem

    • Phoenix tests run with 7 parallel workers without issues
    • The app handles concurrent logins, database operations, and session management properly
    • If tests fail with parallelism, it's usually a test timing issue, not infrastructure
    • Playwright's browser context isolation is robust - each worker gets isolated cookies/sessions
  2. waitForTimeout is almost always wrong

    • page.waitForTimeout() is the #1 cause of flakiness in Phoenix tests
    • Arbitrary timeouts race against rendering and network speed
    • Always replace with state-based waits:
      typescript
      // ❌ BAD - flaky, races against rendering
      await page.waitForTimeout(500);
      await element.click();
      
      // ✅ GOOD - waits for actual state
      await element.waitFor({ state: "visible" });
      await element.click();
  3. Test the actual failure before fixing

    • Run tests with parallelism enabled to see what actually fails
    • Check error messages - they often point to the real issue
    • Don't optimize prematurely (e.g., caching auth state) if it's not the problem
  4. Phoenix test infrastructure is solid

    • In-memory SQLite works fine with parallel tests
    • No need for per-worker databases
    • No need for auth state caching
    • Tests use randomUUID() for data isolation - this works well

Debugging Workflow

When tests are flaky:

  1. Run with parallelism multiple times to catch intermittent failures:

    bash
    for i in 1 2 3 4 5; do
      pnpm exec playwright test --project=chromium --reporter=dot
    done
  2. Look for waitForTimeout usage - replace with proper waits:

    bash
    grep -r "waitForTimeout" js/app/tests/
  3. Check for race conditions in element interactions:

    • Wait for element visibility before interacting
    • Wait for network idle when needed: page.waitForLoadState("networkidle")
    • Use waitForURL after navigation actions
  4. Verify selectors are stable:

    • Avoid CSS selectors that depend on DOM structure
    • Use role/label selectors that match ARIA attributes
    • Test selectors don't break when UI updates
  5. Run with trace on failure to see what happened:

    bash
    pnpm exec playwright test --trace on-first-retry

Common Flaky Patterns and Fixes

Flaky PatternRoot CauseFix
Submenu item not foundUsing getByText() instead of getByRole()Use getByRole("menuitem", { name: /pattern/i }) for submenu items
Menu click failsMenu not fully renderedawait menu.waitFor({ state: "visible" }) before click
Dialog assertion failsDialog animation not completeAssert specific completion signal (hidden dialog + next-state element)
Navigation timeoutPage still loadingRemove waitForLoadState("networkidle") - it's flaky in CI
Element not foundDynamic content loadingWait for element visibility, not arbitrary timeout
Stale elementRe-render between locate and clickStore locator, not element handle

Test Stability Best Practices

  1. Use proper waits:

    typescript
    // Wait for element state
    await element.waitFor({ state: "visible" | "hidden" | "attached" })
    
    // Wait for network
    await page.waitForLoadState("networkidle" | "domcontentloaded" | "load")
    
    // Wait for URL change
    await page.waitForURL("**/expected-path")
  2. Use unique test data:

    typescript
    const uniqueName = `test-${randomUUID()}`;
  3. Prefer role selectors - they're less brittle:

    typescript
    page.getByRole("button", { name: "Save" }) // ✅ Good
    page.locator('button.save-btn') // ❌ Brittle
  4. Don't fight animations - wait for them:

    typescript
    await expect(dialog).not.toBeVisible();
  5. Verify URL changes after navigation:

    typescript
    await page.waitForURL("**/datasets");

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Phoenix Playwright Tests」では何ができますか?

Phoenix AIオブザーバビリティプラットフォーム向けのPlaywright E2Eテストを作成します。Playwrightテストの作成、更新、デバッグのほか、UI機能のテスト、E2Eテストの作成、Phoenixでのブラウザー操作の自動化についてユーザーから依頼されたときに使用します。

TypingMindでPhoenix Playwright Testsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Phoenix Playwright Testsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにPhoenix Playwright Testsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Arize-ai/phoenix/tree/main/.agents/skills/phoenix-playwright-testsを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Phoenix Playwright Testsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Phoenix Playwright Testsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもPhoenix Playwright Testsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Phoenix Playwright Tests」は無料ですか?

Arize-aiがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇