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 🙏

© 2024 – Pkg Stats / Ryan Hefner

playwright-ai-bot

v1.5.0

Published

PlayBot is an AI-powered CLI tool designed to accelerate the development and maintenance of Playwright test automation.

Downloads

1,661

Readme

Playwright AI Bot (PlayBot) - early preview

PlayBot is an AI-powered CLI tool designed to accelerate the development and maintenance of Playwright test automation.

Features

  • Web app crawling for data collection
  • AI-driven generation and updating of:
    • User stories
    • Test cases
    • Executable code

Demo project for first experiments

For first experiments, we created a demo project with basic setup.

Installation

npm install --save-dev playwright-ai-bot

Usage

npx playwright-ai-bot <command> [options]

Commands

| Command | Description | | ------------- | ----------------------------------- | | crawl <url> | Crawl the web app and collect data | | stories | Generate user stories | | tests | Generate test cases from stories | | code | Generate executable code from tests |

Usage: playwright-ai-bot [options] [command]

PlayBot: AI-powered CLI tool that speeds up the development and maintenance of Playwright test automation.

Options:
  -V, --version          output the version number
  -h, --help             display help for command

Commands:
  crawl [options] [url]  Simple crawler for the tested web apps to collect data about it and generate user stories, test cases, and code. For more complex
                         use cases, please provide your own implementation and store data in the playbot-data folder (screenshot, html, minimized html) or
                         contact us to integrate it with Wopee.io bot.
  stories [options]      Create a new story
  tests [options]        Create a new test
  code                   Create or update code based on the provided test cases
  help [command]         display help for command

Configuration

Create a playbot.config.js file in your project root:

const config = {
  baseUrl: 'https://dronjo.wopee.io',
  aiModel: 'gpt-4o-mini',
  apiKey: process.env.OPENAI_API_KEY || '',
  frameworkPath: 'docs',
  framework: 'playwright', // Not implemented yet (TODO): playwright, cypress, robot-framework, webdriver-io
  frameworkPath: 'tests',
};

// CommonJS export = type: "commonjs" in package.json (default behavior)
module.exports = config;

// ES Module export = type: "module" in package.json
// export default config;

Set up your .env file with the Open AI API key:

OPENAI_API_KEY=super-secret-key

Authentication and cookies handling

This is very early version - feedback more than welcome.

  1. Open Playwright codegen tool: npx playwright codegen --save-storage=auth.json
  2. Stop recording
  3. Navigate through the pages you want to crawl later to record storage to be reused during crawling.
  4. Close the Playwright codegen
  5. You should get auth.json with storage content

This is example from Sauce demo app after logging in with standard_user

{
  "cookies": [
    {
      "name": "session-username",
      "value": "standard_user",
      "domain": "www.saucedemo.com",
      "path": "/",
      "expires": 1729532645,
      "httpOnly": false,
      "secure": false,
      "sameSite": "Lax"
    }
  ],
  "origins": [
    {
      "origin": "https://www.saucedemo.com",
      "localStorage": [
        {
          "name": "backtrace-guid",
          "value": "d3575904-a4dc-4139-a1a0-01f25a69e5c4"
        },
        {
          "name": "backtrace-last-active",
          "value": "1729532012509"
        }
      ]
    }
  ]
}
  1. Adjust your config file: add crawlerStorageState: 'auth.json' into playbot.config.json file.
...
const config = {
  ...
  crawlerStorageState: 'auth.json',
  ...
};
...

Troubleshooting: you can easily test your auth.json is created properly by running: npx playwright codegen --load-storage=auth.json [you-web-app] and you should be logged in.

Debugging (only for development)

  • npm run dev -- crawl https://dronjo.wopee.io
  • npm run dev -- stories
  • npm run dev -- tests
  • npm run dev -- code

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a new branch: git checkout -b feature/your-feature-name
  3. Make your changes and commit them: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature/your-feature-name
  5. Submit a pull request

For major changes, please open an issue first to discuss what you would like to change.

License

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