npm.io
1.1.0 • Published 5 years agoCLI

playwright-start

Licence
MIT
Version
1.1.0
Deps
2
Size
8 kB
Vulns
0
Weekly
0
Stars
30

playwright-start Latest version Monthly downloads

Start a long-running Playwright browser server via CLI.

If you like this project, please star 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

Keywords