xk6-browser brings browser automation and end-to-end web testing to k6 while supporting core k6 features. It adds browser-level scripting APIs to interact with real browsers and collect frontend metrics as part of your k6 tests.
Installation
xk6-browser is currently being developed as a k6 extension. You have to run a k6 version built with the browser extension to use the browser-level APIs in your k6 tests.
Download a release binary
The quickest way to get started is to download a release binary from GitHub.
Build from source
If you're more adventurous or want to get the latest changes of the xk6-browser extension, you can also build from source.
To build a k6 binary with the extension, first, ensure you have installed Go and Git; the following steps are:
xk6 will create the k6 binary in the local folder.
To learn more about how to build custom k6 versions, check out xk6
Browser-level APIs
xk6-browser uses Chrome DevTools Protocol to instrument and interact with the browser. The xk6-browser APIs aims for rough compatibility with the Playwright API for NodeJS.
Note that because k6 does not run in NodeJS, xk6-browser APIs will slightly differ from their Playwright counterparts.
Here's a list of the fully (✅) or partially (🚧) implemented classes of the Playwright API (with a more detailed breakdown of missing APIs in the table below):
The following Playwright APIs are not supported yet: