Command Line Interface
Playwright comes with the command line tools that run via
npx or as a part of the
codegen will attempt to generate resilient text-based selectors.
#Preserve authenticated state
--save-storage to save cookies and localStorage at the end. This is useful to separately record authentication step and reuse it later.
--load-storage to consume previously loaded storage. This way, all cookies and localStorage will be restored, bringing most web apps to the authenticated state.
open, you can use Playwright bundled browsers to browse web pages. Playwright provides cross-platform WebKit builds that can be used to reproduce Safari rendering across Windows, Linux and macOS.
open can emulate mobile and tablet devices from the
#Emulate color scheme and viewport size
#Emulate geolocation, language and timezone
codegen, you can use following API inside the developer tools console of any browser.
Query Playwright selector, using the actual Playwright query engine, for example:
playwright.$, but returns all matching elements.
Reveal element in the Elements panel (if DevTools of the respective browser supports it).
Generates selector for the given element.
PDF generation only works in Headless Chromium.
Opening WebKit Web Inspector will disconnect Playwright from the browser. In such cases, code generation will stop.