This is the puppeteer-core browser provider plugin for TestCafe.
This package implements the puppeteer browser automation for TestCafe.
This browser provider plugin can:
- connect to remote Chromium instance through the DevTools Protocol
- download a recent Chromium build (if not already downloaded) and use it for the tests
- launch a specific Chromium executable
Same as with the official puppeteer-core
package, this package doesn't download Chromium when installed.
npm install testcafe-browser-provider-puppeteer-core
There are two browser aliases available:
puppeteer-core:connect
puppeteer-core:launch
Parameters can be passed to a browser alias using a URL query string (URL encoded or not):
puppeteer-core:browser_alias_name?param1=value¶m2=value¶m3=value
puppeteer-core:connect
connects to a remote Chromium instance through the DevTools Protocol.
Parameters:
url
: the url to connect to the remote Chromium instance (defaults tohttp://127.0.0.1:9222
).resolve
: whether or not to resolve the hostname in the url as a workaround to the issue described in GoogleChrome/puppeteer#2242 (defaults to false).
Example:
The command below launches a headless-shell build of Chromium in a Docker container:
docker run -d --rm -p 9222:9222 --entrypoint '/headless-shell/headless-shell' chromedp/headless-shell --no-sandbox --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222
Run the tests using the the Chromium instance launched above:
testcafe 'puppeteer-core:connect?url=http://127.0.0.1:9222' 'path/to/test/file.js'
puppeteer-core:launch
downloads (optional) and launches a Chromium executable.
Parameters:
revision
: revision of the bundled Chromium to download and launch (see https://omahaproxy.appspot.com for the list of revision). Defaults to thepuppeteer-core
package recommended version.path
: path to a Chromium (or Chrome) executable to run instead of the bundled Chromium (optional).headless
: whether or not to run Chromium headless (defaults totrue
).arg
: extra command line arguments to pass to Chromium (repeat thearg
parameter to pass multiple arguments).
NOTE: if the path
parameter is used, revision
is ignored and Chromium won't be downloaded if the executable is not found.
Example:
Run the tests using the bundled Chromium (it will download it if not found locally):
testcafe 'puppeteer-core:launch' 'path/to/test/file.js'
Run the tests using a specific bundled Chromium revision (it will download it if not found locally):
testcafe 'puppeteer-core:launch?revision=693954' 'path/to/test/file.js'
Run the tests using the bundled Chromium (it will download it if not found locally) and the --no-sandbox
and --disable-setuid-sandbox
Chromium arguments:
testcafe 'puppeteer-core:launch?arg=--no-sandbox&arg=--disable-setuid-sandbox' 'path/to/test/file.js'
Run the tests using a specific Chromium executable:
testcafe 'puppeteer-core:launch?path=/my/path/to/chromium' 'path/to/test/file.js'
Please read the Testcafe browser provider plugin documentation.
To test the browser provider while developing, you can link the browser provider to TestCafe by using the npm link
command:
First, link the browser provider package:
cd testcafe-browser-provider-puppeteer-core
npm link
Then, to use the local package in your project:
cd my-project
npm link testcafe-browser-provider-puppeteer-core