Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

Playwright MCP テスト

このプロジェクトは、Model Context Protocol (MCP) を使用してPlaywrightによるブラウザ自動操作をAIモデルから制御するテスト環境です。Google GeminiまたはOpenAIのモデルを使用して、Playwrightツールを通じてWebブラウザを操作できます。

機能

  • PlaywrightによるWebブラウザの自動操作
  • Google GeminiまたはOpenAIのLLMモデルを選択可能
  • 操作中のスクリーンショットの自動保存
  • LangChainとLangGraphによるツール呼び出しフロー制御

必要条件

  • Python 3.8以上
  • Playwrightがインストールされたブラウザ
  • Google GeminiまたはOpenAIのAPIキー

インストール

  1. リポジトリをクローンするか、ファイルをダウンロードします。

  2. 依存パッケージをインストールします:

pip install -r requirements.txt
  1. 環境変数を設定します:
# Google Geminiを使用する場合
export GOOGLE_APIKEY=your_google_api_key

# OpenAIを使用する場合
export OPENAI_API_KEY=your_openai_api_key

Windowsの場合は以下のコマンドを使用します:

# Google Geminiを使用する場合
set GOOGLE_APIKEY=your_google_api_key

# OpenAIを使用する場合
set OPENAI_API_KEY=your_openai_api_key

設定

mcp_config.jsonファイルで、使用するモデルとMCPサーバーの設定を行います:

{
  "modelConfig": {
    "provider": "google",  // "google" または "openai"
    "models": {
      "google": {
        "model": "gemini-2.0-flash",  // または別のGeminiモデル
        "temperature": 0.1
      },
      "openai": {
        "model": "gpt-4.1-mini",  // または別のOpenAIモデル
        "temperature": 0.1
      }
    }
  },
  "mcpServers": [
    {
      "url": "http://localhost:8000",  // PlaywrightのMCPサーバーURL
      "tools": ["browser_*"]  // 使用するツールパターン
    }
  ]
}

使用方法

  1. スクリプトを実行します:
python playwright_mcp_langchain_tools.py
  1. プロンプトが表示されたら、実行したいブラウザ操作を日本語で入力します。例:

    • "Googleのトップページにアクセスして検索してください"
    • "ウィキペディアで人工知能について調べてください"
  2. AIがPlaywrightを使ってブラウザを操作し、スクリーンショットを保存します。

  3. 終了するには、exitまたはquitと入力します。

スクリーンショット

スクリーンショットは自動的にscreenshotsディレクトリに保存されます。ファイル名は日時とカウンターに基づいて生成されます。

注意事項

  • ブラウザ操作は実際のブラウザを使用するため、操作中はブラウザウィンドウが開きます。
  • ネットワークエラーが発生した場合は、コマンドを再実行してみてください。
  • 複雑な操作や長時間の操作の場合は、適切なタイムアウト設定が必要な場合があります。
  • GPT-4.1-nanoの場合、正しくスクリーンショットを取得できない場合があります。
  • 操作が長い場合、LLMの戻りが遅くなります。今後入力トークン数の圧縮などを行い、対策を行う予定です。

トラブルシューティング

  • APIキーが正しく設定されていることを確認してください
  • MCPサーバーが正しく起動していることを確認してください
  • Playwrightが正しくインストールされていることを確認してください

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    3.1 (11)
    Avatar
    user_WnnaT0kj
    2025-04-24

    As a dedicated user of MCP applications, I'm thrilled with the playwright-mcp-test by s-ono-123456. It offers seamless user interaction and intuitive navigation, making automated testing efficient and straightforward. The start URL setup was clean, and the welcome information ensured a smooth onboarding experience. Highly recommend for anyone in need of reliable test automation solutions!

    Avatar
    user_zF7SKuU1
    2025-04-24

    I've been using the Playwright-MCP-Test by s-ono-123456 and it has completely surpassed my expectations. The ease of navigation and the efficiency in testing has made my workflow much smoother. Highly recommend this to anyone looking for a reliable testing tool!

    Avatar
    user_kOLjt109
    2025-04-24

    I recently used the Playwright-MCP-Test authored by s-ono-123456 and it exceeded my expectations! The user-friendly interface and seamless integration into my existing system made testing smooth and efficient. The comprehensive welcome information guided me through the initial setup effortlessly. Highly recommend this for anyone looking to enhance their testing capabilities!

    Avatar
    user_4kdDLGHw
    2025-04-24

    I have been using playwright-mcp-test by s-ono-123456 and it has been an absolute game-changer for my workflow. The seamless integration and ease of use make it a must-have for any serious developer. The product is well-supported and constantly updated. Highly recommend!

    Avatar
    user_4NYFOb2t
    2025-04-24

    I've been using the Playwright-MCP-Test by s-ono-123456 and it has significantly streamlined my testing process. It's incredibly user-friendly and integrates seamlessly with my workflow. The starting URL and welcome information are clear and helpful, making the setup a breeze. Highly recommended for anyone in need of a robust testing tool!

    Avatar
    user_9xdfHf8i
    2025-04-24

    I have been using the Playwright MCP Test from s-ono-123456 and it has significantly streamlined my web application testing process. The seamless integration and user-friendly interface make automated testing incredibly efficient. Highly recommend it to fellow developers!

    Avatar
    user_YPRwjO28
    2025-04-24

    I've been using playwright-mcp-test by s-ono-123456, and it’s truly impressive! This tool simplifies automated testing with ease, enhancing productivity considerably. The clean interface and efficient functionality make it a must-have for any development workflow. Highly recommend it!

    Avatar
    user_kekfuooh
    2025-04-24

    I've been using "playwright-mcp-test" by s-ono-123456 and it's simply outstanding. The seamless integration and user-friendly interface provide an excellent experience. Whether you are new to MCP applications or a seasoned user, this product will exceed your expectations. Highly recommended!

    Avatar
    user_GSQFqhpc
    2025-04-24

    As a devoted user of the mcp application, I am thrilled with the playwright-mcp-test created by s-ono-123456. This tool has significantly streamlined my testing process. It is intuitive, efficient, and provides reliable results. Highly recommended for anyone seeking to enhance their test automation.

    Avatar
    user_YBoR9ETR
    2025-04-24

    Playwright-mcp-test is an exceptional tool for automated testing. Created by s-ono-123456, it offers robust performance and efficient test execution. This tool is easy to use and well-documented, making it perfect for both beginners and experienced developers. Highly recommend!

    Avatar
    user_WHVKNpbn
    2025-04-24

    I've been using playwright-mcp-test by s-ono-123456 and it's truly impressive. The application performs seamlessly, making test automation smooth and efficient. The setup was straightforward, and the welcome information guided me perfectly. Highly recommended for anyone looking to streamline their testing processes!