MCP ExplorerExplorer

Playwrite Browser Automation Mcp

@ShubhamDalvi1999on a year ago
1 MIT
FreeCommunity
AI Systems
Automated tests for Sauce Demo website using Playwright and Python.

Overview

What is Playwrite Browser Automation Mcp

Playwrite-Browser-automation-MCP is a Python framework designed for automated testing of web applications using the Playwright library. It specifically targets the Sauce Demo website to validate its functionalities through various test scenarios.

Use cases

Use cases for Playwrite-Browser-automation-MCP include validating user login processes, ensuring error handling for locked accounts, and testing the overall functionality of web applications to ensure they meet user expectations.

How to use

To use Playwrite-Browser-automation-MCP, first install the required dependencies by running ‘pip install -r requirements.txt’. Then, install the necessary Playwright browsers using ‘python -m playwright install’. You can run tests using ‘pytest’, and specify options for verbosity or specific browsers as needed.

Key features

Key features of Playwrite-Browser-automation-MCP include support for multiple browsers (Chromium, Firefox, WebKit), a structured project layout using the Page Object Model for better maintainability, and the ability to run specific tests with detailed output.

Where to use

Playwrite-Browser-automation-MCP is suitable for web application testing in various domains, including e-commerce, SaaS platforms, and any web-based services where automated testing can enhance quality assurance.

Content

Playwright Python Framework

This project contains automated tests for the Sauce Demo website using Playwright with Python.

Project Structure

playwright-python-framework/
|--requirements.txt
|--pages/
|    |--__init__.py
|    |--login_page.py
|--tests/
|    |--test_login.py
|    |--pytest.ini
|    |--conftest.py
|--README.md

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Install Playwright browsers:
python -m playwright install

Running Tests

To run all tests:

pytest

To run with verbose output:

pytest -v

To run with a specific browser:

pytest --browser-name=firefox

Available browser options:

  • chromium (default)
  • firefox
  • webkit

To run a specific test:

pytest tests/test_login.py::test_valid_login -v

Test Scenarios

The framework currently includes the following test scenarios:

  1. Valid Login Test

    • Navigates to the login page
    • Logs in with valid credentials (standard_user)
    • Verifies successful redirection to inventory page
    • Verifies login form is no longer visible
  2. Locked Out User Test

    • Navigates to the login page
    • Attempts to log in with locked_out_user credentials
    • Verifies user remains on login page
    • Verifies appropriate error message is displayed

Page Object Model

This framework uses the Page Object Model design pattern:

  • login_page.py - Contains methods and selectors for the login page
  • Tests interact with pages through these objects rather than directly with UI elements

Technologies Used

  • Playwright - Browser automation library
  • pytest - Testing framework
  • pytest-playwright - Pytest plugin for Playwright integration

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers