npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

playwright-with-yaml

v1.0.1

Published

Run Playwright tests using YAML configuration files.

Readme

Automation Testing Framework with Playwright and YAML

This is a simple automation testing framework designed to execute web application tests using Playwright with test scenarios written in YAML format. The framework allows easy configuration and flexibility in defining test steps for a variety of web interactions.

Project Structure

The project is organized as follows:

my-automation-framework/
│
├── config/           # Framework configuration files
│   ├── test-config.yaml  # YAML configuration for global settings (base URL, credentials, timeout, etc.)
│
├── tests/            # Contains test files
│   └── login-test.yaml  # Example test case in YAML (Login Test)
│
├── src/              # Core code for running tests
│   ├── runner.js     # Script to load and run tests
│   └── executor.js   # Executor for performing actions defined in YAML test cases
│
├── package.json      # Node.js dependencies and scripts
└── README.md         # This documentation

Configuration File (test-config.yaml)

In the config directory, the test-config.yaml file holds global configurations for the tests, such as the base URL of the application, credentials, and timeout values.

Example test-config.yaml

base_url: "https://www.saucedemo.com"   # Base URL for your web application
credentials:
  username: "standard_user"             # Username for login
  password: "secret_sauce"              # Password for login
timeout: 5000                           # Timeout for each action (in milliseconds)

Test Case File (login-test.yaml)

In the tests directory, YAML files describe the test cases. The steps for each test case include actions like opening a page, typing in a field, clicking buttons, waiting for elements, and verifying visibility.

Example login-test.yaml

test_name: "Login Test"
steps:
  - action: "open"
    url: "{{base_url}}"
  
  - action: "type"
    selector: "#user-name"
    value: "{{credentials.username}}"
  
  - action: "type"
    selector: "#password"
    value: "{{credentials.password}}"
  
  - action: "click"
    selector: "#login-button"

  - action: "wait"
    selector: ".inventory_list"  # Wait for the element that confirms the page is loaded
  
  - action: "verify"
    selector: ".inventory_list"
    condition: "visible"

Core Files

src/executor.js

The core file that interprets the YAML test steps and interacts with the browser using Playwright.

  • Opens the browser.
  • Fills forms, clicks buttons, and waits for elements.
  • Verifies the visibility of elements as defined in the test.

src/runner.js

This file loads the test case and configuration files, then runs the tests using the executor.js functions.

const { runTest, loadTestCases, loadConfig } = require('./executor');
const path = require('path');

// Load configuration and test case
const config = loadConfig(path.join(__dirname, '../config/test-config.yaml'));
const testCase = loadTestCases(path.join(__dirname, '../tests/login-test.yaml'));

// Run the test
runTest(testCase, config).catch(error => console.error(error));

Installation

To get started with this automation testing framework, follow the steps below:

  1. Clone the repository:

    git clone <repository-url>
  2. Navigate into the project folder:

    cd my-automation-framework
  3. Install the dependencies:

    npm install
  4. You may need to install Playwright separately if it isn't already installed:

    npx playwright install

Running the Tests

To run the tests, simply execute the runner.js file with Node.js:

node src/runner.js

This will load the test case defined in login-test.yaml and execute it based on the configuration from test-config.yaml.

Customizing Your Tests

  1. Adding New Test Cases: To add a new test case, create a new YAML file in the tests directory, similar to login-test.yaml, and define your test steps.

  2. Configuring Test Settings: Modify test-config.yaml to update global settings such as the base URL, login credentials, and timeout values.

  3. Modify Timeouts: The timeout for each action can be configured globally in test-config.yaml. You can increase or decrease the timeout for waiting, clicking, or typing actions.

Supported Actions in Test Cases

  • open: Opens the URL (defined in the test case) in the browser.
  • type: Types a value into the specified selector.
  • click: Clicks on the specified element.
  • wait: Waits for an element to appear on the page.
  • verify: Verifies that an element is visible on the page.

Troubleshooting

  • Ensure that Playwright is installed correctly by running npx playwright install.
  • If tests run too quickly, adjust the timeout values in the configuration file to allow more time for actions like clicking and waiting for elements.

License

This project is licensed under the MIT License - see the LICENSE file for details.


This README.md provides a comprehensive guide to getting started with the automation testing framework, from installing the project to running and customizing tests. Feel free to modify the configurations and test cases according to your needs!