✍️ An authoring tool for playwrights.
npm install scriptwriterLearn what Playwright can do in each of the various browsers it supports. By default, Scriptwriter loads Chromium and creates a Chrome Devtools Protocol (CDP) client for more repl fun!
!node

1. Ensure you have node 10.15.0 or higher.
1. Install Playwright globally: npm i -g playwright (tested with 1.5.2).
1. Install Scriptwriter: npm i -g scriptwriter.
1. (some tools that manage multiple versions of node may require you to npm link playwright for scriptwriter's global-import to work).
1. Or clone this repo, install, and use npm link or npm start.
1. scriptwriter --no-headless will launch the repl and Chromium.
1. Use await right away: await page.goto('https://github.com')
1. The prompt will change on load: github.com ~>
1. .help lists the global commands.
1. Pressing Tab twice will display autocomplete help.
1. Save and load your repl sessions!
You can use cli flags to set the config scriptwriter --help:
```
Usage
$ scriptwriter [--no-headless] [--device
[--browser
Options
--no-headless, --no-h Run as headless=false
--device, -d Load a device profile from Playwright
--config, -c Pass a config file to Scriptwriter
--browser, -b Change browsers (default: chromium)
--no-js Disable JavaScript
--no-csp Bypass CSP
--aom, -a Launch with Accessibility Object Model (AOM) enabled
--user, -u Launch with a Persistent Context
Examples
$ scriptwriter
$ scriptwriter --no-headless
$ scriptwriter --device 'iPhone X'
$ scriptwriter --config ./config.js
$ scriptwriter -c ./config.json --no-h
$ scriptwriter --no-js --b firefox
You can also load a config from a file.
`json`
// iphonex.json
{
"launch": {
"headless": true,
"args": ["--some-blink-specific-tag-name"]
},
"context": {},
"device": "iPhone X"
}
scriptwriter --config iphonex.json
You can load your own commands. Scriptwriter exposes some helpful utility functions.
- director = node repl instance
- scriptwriter.code = prettier.format
- scriptwriter.color = kleur
- scriptwriter.error = pretty-error
- scriptwriter.escapes = ansi-escapes
- scriptwriter.importGlobal = import-global
Example:
`jsmake something louder
// my-command.js
scriptwriter.completion = '.louder';
director.defineCommand('louder', {
help: ,${str.toUpperCase()}!!
async action(str) {
const { log, color } = scriptwriter;
log(color.red());`
director.displayPrompt();
},
});
`js`
// in the scriptwriter repl
> .load my-command.js
> .louder test
TEST!!
On a mac, you may get the firewall popup.
1. Open keychain access.
1. In the top menu, choose Keychain Access > Certificate Assistant > Create a Certificate.Playwright
1. Name it .Certificate Type
1. Change the to Code Signing.create
1. Click .Get Info
1. Right click your new certificate and choose .Trust
1. Open disclosure.When using this certificate:
1. Change to Always Trust.Options > Show in Finder
1. Start Scriptwriter.
1. When Chromium starts, right click the icon in the menu bar, choose .New Terminal Here
1. Right click Chromium and select .pwd
1. In the terminal type and copy the path.sudo codesign -s Playwright -f
1. Use the following to assign the certificate: