DevOps AI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
No Result
View All Result
Home AI & Automation

Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

devopsify by devopsify
16 Tháng 6, 2025
in AI & Automation
0
Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent
Share on FacebookShare on Twitter

Trong thời đại AI và automation, việc kết hợp GitHub Copilot Agent với browser automation đã mở ra những khả năng mới thú vị cho developers. Playwright MCP (Model Context Protocol) server là công cụ cho phép AI agents như GitHub Copilot tương tác trực tiếp với web browsers, mang đến trải nghiệm automation hoàn toàn mới. Trong bài viết này, chúng ta sẽ khám phá cách sử dụng VS Code với Playwright MCP để cho phép GitHub Copilot Agent tự động tương tác với website demo Demoblaze.

Playwright MCP là gì?

Hiểu về Model Context Protocol (MCP)

Model Context Protocol (MCP) là một chuẩn mở cho phép các AI models tương tác với external tools và services thông qua một giao diện thống nhất. Cụ thể với Playwright MCP:

  • Không phải là testing framework: MCP là một server protocol, không phải framework testing
  • Bridge cho AI agents: Cho phép LLM/AI agents điều khiển browser thông qua Playwright
  • Structured accessibility snapshots: Sử dụng accessibility tree của browser thay vì screenshots, giúp LLM hiểu được cấu trúc trang web một cách structured
  • Fast and lightweight: Nhanh hơn và nhẹ hơn các phương pháp dựa trên visual analysis

Playwright MCP hoạt động như thế nào?

Playwright MCP hoạt động chủ yếu ở hai chế độ: Snapshot Mode (mặc định) sử dụng accessibility tree của browser để hiểu cấu trúc trang web, và Vision Mode sử dụng screenshots cho các tương tác phức tạp hơn.

Snapshot Mode mang lại những ưu điểm:

Related Post

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

16 Tháng 6, 2025
DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

13 Tháng 6, 2025

DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên

7 Tháng 6, 2025

Ưu Đãi Đặc Biệt: Nhận Ngay Coupon Giảm 25% cho Bộ Đề Luyện Thi Cloud!

29 Tháng 4, 2025
  • Fast: Tạo và parse accessibility tree nhanh hơn nhiều so với xử lý screenshots
  • LLM-friendly: LLM xử lý structured text data hiệu quả hơn
  • Deterministic: Tránh sự mơ hồ thường gặp với screenshot-based approaches

Tại sao chọn VS Code với GitHub Copilot Agent?

GitHub Copilot Agent Mode

GitHub Copilot Agent Mode là tính năng mới cho phép Copilot thực hiện các hành động complex, từ việc sửa lỗi code generation đến xây dựng webapp, thậm chí tương tác với external services.

Agent Mode có khả năng:

  • Action-oriented: Không chỉ trả lời câu hỏi mà thực hiện các task cụ thể
  • Multi-step execution: Thực hiện các subtasks tự động để hoàn thành mục tiêu chính
  • Tool integration: Tích hợp với MCP servers để mở rộng capabilities
  • Self-healing: Phân tích runtime errors và tự sửa lỗi

MCP Integration trong VS Code

VS Code hỗ trợ MCP servers từ phiên bản 1.99, cho phép GitHub Copilot Agent kết nối với external tools và services. Điều này mở ra khả năng:

  • Database interactions: Kết nối và query databases
  • API calls: Gọi các external APIs
  • File operations: Thao tác với file system
  • Browser automation: Điều khiển web browsers thông qua Playwright

Giới thiệu về Demoblaze – Target website lý tưởng

Demoblaze vẫn là lựa chọn tuyệt vời cho việc thực hành browser automation với AI:

Ưu điểm của Demoblaze:

  • Complete e-commerce features: Product catalog, shopping cart, user authentication
  • Stable structure: Cấu trúc ổn định, phù hợp cho AI learning
  • Realistic scenarios: Các tình huống giống thực tế
  • Good accessibility: Accessibility tree rõ ràng, thuận lợi cho Playwright MCP

Các tính năng chính:

  • Product browsing: Duyệt sản phẩm theo categories
  • Shopping flow: Thêm vào giỏ hàng và checkout
  • User registration: Đăng ký và đăng nhập
  • Responsive design: Hoạt động tốt trên mobile và desktop
Automation Demo site Demoblaze

Cài đặt và cấu hình Playwright MCP

Bước 1: Chuẩn bị môi trường

Yêu cầu hệ thống:

  • Node.js (LTS version)
  • VS Code 1.99 hoặc mới hơn
  • GitHub Copilot và GitHub Copilot Chat extensions
  • Đăng nhập GitHub trong VS Code

Bước 2: Kích hoạt MCP support trong VS Code

  1. Mở VS Code Settings (Ctrl+,)
  2. Tìm kiếm chat.mcp.enabled
  3. Bật setting này để enable MCP support trong agent mode

Bước 3: Cài đặt Playwright MCP Server

Phương pháp 1: Sử dụng VS Code CLI

Cài đặt Playwright MCP server

# Cài đặt Playwright MCP server
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'

Phương pháp 2: Cấu hình manual trong workspace

Tạo file .vscode/mcp.json trong workspace:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--browser", "chromium",
        "--headless"
      ]
    }
  }
}

Phương pháp 3: Global settings

Thêm vào VS Code settings.json:

{
  "mcp": {
    "servers": {
      "playwright": {
        "command": "npx",
        "args": [
          "@playwright/mcp@latest",
          "--browser", "msedge"
        ]
      }
    }
  }
}

Bước 4: Verify MCP Server

  1. Sử dụng command palette (Ctrl+Shift+P)
  2. Chạy MCP: List Servers
  3. Kiểm tra và start Playwright MCP server nếu cần

Sử dụng GitHub Copilot Agent với Demoblaze

Kích hoạt Agent Mode

  1. Mở GitHub Copilot Chat (Ctrl+Shift+I)
  2. Trong prompt box, chọn “Agent” mode từ dropdown
  3. Click vào tools button để select các tools muốn agent sử dụng

Ví dụ thực hành 1: Browse products trên Demoblaze

Prompt cho Agent:

Navigate to demoblaze.com, browse the Phones category, and give me a summary of the available phones with their prices.

Agent sẽ thực hiện:

  1. Mở browser với Demoblaze
  2. Click vào Phones category
  3. Thu thập thông tin sản phẩm
  4. Tổng hợp và báo cáo kết quả

Ví dụ thực hành 2: Shopping flow automation

Prompt cho Agent:

Go to demoblaze.com, add the first phone to cart, then navigate to cart and show me the details of the added product.

Quy trình Agent thực hiện:

  1. Navigate đến homepage
  2. Click vào sản phẩm đầu tiên trong Phones
  3. Add to cart và handle confirmation dialog
  4. Navigate đến cart page
  5. Extract và report product details

Ví dụ thực hành 3: Comparative analysis

Advanced prompt:

Visit demoblaze.com and compare the price range between Phones, Laptops, and Monitors categories. Create a summary table showing min, max, and average prices for each category.

Agent workflow:

  1. Browse từng category
  2. Collect price data
  3. Perform calculations
  4. Generate formatted comparison table

Advanced Configuration Options

Customizing Browser Behavior

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--browser", "chromium",
        "--headless",
        "--user-data-dir", "./browser-profile"
      ]
    }
  }
}

Vision Mode cho phức tạp interactions

Vision Mode sử dụng screenshots và hoạt động tốt với computer use models có thể tương tác dựa trên tọa độ X,Y:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--vision"
      ]
    }
  }
}

Isolated vs Persistent Profiles

Isolated mode (mỗi session độc lập):

{
  "args": [
    "@playwright/mcp@latest",
    "--isolated"
  ]
}

Persistent profile (giữ lại login state):

{
  "args": [
    "@playwright/mcp@latest",
    "--user-data-dir", "./persistent-profile"
  ]
}

Các Use Cases thực tế với Demoblaze

1. E-commerce Testing với AI

Prompt:

Test the complete shopping flow on demoblaze.com: browse products, add multiple items to cart, and verify the cart total calculation is correct.

2. UI/UX Analysis

Prompt:

Analyze the user experience on demoblaze.com navigation. Check if all category links work properly and report any accessibility issues.

3. Data Extraction

Prompt:

Extract all product information from demoblaze.com including names, prices, and descriptions. Format the data as a JSON structure.

4. Performance Monitoring

Prompt:

Monitor the page load times for different sections of demoblaze.com and identify any performance bottlenecks.

Troubleshooting và Best Practices

Common Issues và Solutions

MCP Server không start:

  1. Kiểm tra Node.js installation
  2. Verify network connectivity
  3. Check VS Code permissions

Browser không mở:

  1. Trên Windows, cần cài đặt Chrome trước khi chạy tests
  2. Kiểm tra browser path configuration
  3. Try different browser options

Agent không sử dụng tools:

  1. Verify MCP server status
  2. Enable tools trong Agent mode interface
  3. Check tool permissions

Performance Optimization

Sử dụng headless mode cho performance:

{
  "args": ["@playwright/mcp@latest", "--headless"]
}

Configure timeout settings:

{
  "args": [
    "@playwright/mcp@latest",
    "--timeout", "30000"
  ]
}

Security và Privacy Considerations

Data Protection

  • Local execution: MCP server chạy local, không gửi data ra external services
  • Controlled access: Có thể restrict tools được phép sử dụng
  • Profile isolation: Sử dụng isolated mode để tránh leak data giữa sessions

Best Security Practices

  1. Review agent requests trước khi approve
  2. Limit tool permissions chỉ những gì cần thiết
  3. Monitor browser activity khi agent đang chạy
  4. Use isolated profiles cho testing purposes

Tương lai của Browser Automation với AI

Emerging Trends

MCP đang trở thành standard cho AI models tương tác với services và applications, đánh dấu kỷ nguyên mới của AI-driven automation. Những xu hướng đáng chú ý:

  • Multi-agent collaboration: Nhiều agents làm việc cùng nhau
  • Context-aware automation: AI hiểu context tốt hơn từ accessibility data
  • Self-improving workflows: Agents học từ user feedback

Integration Opportunities

  • CI/CD pipelines: Tích hợp automated testing với AI agents
  • Monitoring và alerting: AI agents monitor website changes
  • Content management: Automated content updates và validation

Tài nguyên học tập và mở rộng

Chính thức Documentation

  • Playwright MCP GitHub Repository
  • VS Code MCP Documentation
  • GitHub Copilot Agent Mode Guide

Community Resources

  • MCP Servers Repository: Khám phá các MCP servers khác
  • Playwright Documentation: Tìm hiểu sâu về Playwright capabilities
  • Danh sách website demo hay sử dụng cho thực hành automation test – Khám phá thêm target websites

Learning Path Suggestions

  1. Bắt đầu với basic prompts cho simple navigation
  2. Thực hành với complex scenarios như multi-step workflows
  3. Tùy chỉnh MCP configuration cho specific needs
  4. Kết hợp với other MCP servers để mở rộng capabilities

Playwright MCP đã mở ra một chương mới trong browser automation, cho phép GitHub Copilot Agent tương tác intelligently với web applications như Demoblaze. Khác với traditional testing frameworks, MCP mang đến khả năng tự động hóa thông qua natural language prompts, giúp developers và testers làm việc hiệu quả hơn.

Với việc sử dụng accessibility tree thay vì visual analysis, Playwright MCP cung cấp một phương pháp fast, reliable và LLM-friendly cho browser automation. Điều này đặc biệt phù hợp với các website có cấu trúc tốt như Demoblaze.

Tương lai của automation testing đang hướng tới sự kết hợp giữa AI intelligence và traditional tooling. VS Code với Playwright MCP và GitHub Copilot Agent chính là một ví dụ điển hình cho trend này.

Hãy bắt đầu khám phá khả năng của AI-powered browser automation ngay hôm nay và tìm hiểu thêm các kỹ thuật automation khác tại devopsify.co – nơi chia sẻ những kiến thức DevOps và automation testing chất lượng cao.

Tags: agent-modeai-assistantautomation testbrowser-automationdemoblazedevopsgithub-copilotmcpmodel-context-protocolplaywrightvs-code
devopsify

devopsify

Related Posts

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật
AI & Automation

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

by devopsify
16 Tháng 6, 2025
DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code
AI & Automation

DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

by devopsify
13 Tháng 6, 2025
DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên
Bảo mật

DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên

by devopsify
7 Tháng 6, 2025

Để lại một bình luận Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Recommended

Các website demo hay được sử dụng cho thực hành Automation Test

Các website demo hay được sử dụng cho thực hành Automation Test

11 Tháng 6, 2025
Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

1 Tháng 5, 2025
Cài đặt Maven trên Windows

Cài đặt Maven trên Windows

11 Tháng 6, 2025
Cài đặt Grafana – Loki – Promtail monitoring log Container

Cài đặt Grafana – Loki – Promtail monitoring log Container

1 Tháng 5, 2025
Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

16 Tháng 6, 2025
MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

16 Tháng 6, 2025
DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

13 Tháng 6, 2025
GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

11 Tháng 6, 2025
DevOpsify

Cộng đồng DevOps Việt Nam chia sẽ kiến thức giúp tăng tốc quá trình phát triển ứng dụng và tự động hóa trong lĩnh vực Cloud DevOps & AI.

Bài viết mới

  • Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent
  • MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật
  • DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

Categories

  • AI & Automation
  • Bảo mật
  • Chưa phân loại
  • DevOps & Cloud
  • Tin tức
No Result
View All Result
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud

© 2025 DevOpsify