Giter Club home page Giter Club logo

playwright-start's Introduction

playwright-start Latest version Monthly downloads

Start a long-running Playwright browser server via CLI.

Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️

🙋‍♂️ Why?

When developing browser automation scripts, there's a lot of overhead in browser start up every time you test a change.

Start a long-running browser server in a separate window and connect to it from your script to iterate faster! The CLI also comes with a REPL to help you quickly test code.

🚀 Install

npm i -D playwright-start

🚦 Quick Setup

  1. Start a browser server from a separate terminal session:

    npx playwright-start
  2. Connect from your code:

    import {
        ChromiumBrowser,
        devices,
    } from 'playwright'
    import connect from 'playwright-start'
    
    (async () => {
        const browser = await connect<ChromiumBrowser>()
    
        const context = await browser.newContext({
            // Emulate Pixel 2 XL
            ...devices['Pixel 2 XL']
        })
    
        const page = await context.newPage()
    
        // ...
    })()

👨‍🏫 Examples

Starting a non-headless Chromium server

npx playwright-start --headless=false

Starting a Firefox or Webkit server

Firefox:

npx playwright-start firefox

Webkit:

npx playwright-start webkit

playwright-start's People

Contributors

privatenumber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

playwright-start's Issues

Print websocket address to stdout.

I was looking for something that would start a playwright server from the CLI that I could connect to via python. playwright-start looked good except it doesn't print out the websocket address.

It would be a nice addition if this script allowed to specify the wspath and port and also printed them to stdout.

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

Bug description

npx playwright-start failed, it saids:

/Users/xxx/.npm/_npx/7d976fb7a2568a32/node_modules/playwright-start/dist/playwright-start.js:49
    [parsed.options.headless] = parsed.options.headless;
                              ^

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at /Users/xxx/.npm/_npx/7d976fb7a2568a32/node_modules/playwright-start/dist/playwright-start.js:49:31
    at Object.<anonymous> (/Users/xxx/.npm/_npx/7d976fb7a2568a32/node_modules/playwright-start/dist/playwright-start.js:64:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/xxx/.npm/_npx/7d976fb7a2568a32/node_modules/playwright-start/bin/playwright-start.js:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)

Node.js v18.0.0

Reproduction steps

npx playwright-start

Environment

  • playwright-start version:

➜ ~ npx playwright-start --version
start-browser/1.1.0 darwin-x64 node-v18.0.0

  • Operating System:

Darwin xxx-MB0 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

  • Node version: v18.0.0

  • Package manager (npm/yarn/pnpm) and version: npx 8.6.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.