You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you pointed out the Docker image does not include Playwright itself, so you'll have to install it separately, e.g. when running the Docker container you can do something like this:
npm init -y
npm install playwright --save
And then run your script from the same directory.
Alternatively you could bake Playwright into your docker image, e.g. by adding the following line to Docker.bionic:
I am still new to Docker so I am wondering how to execute the simplest playwright JS with node as the dockerfile provided in https://github.com/microsoft/playwright/blob/master/docs/docker/Dockerfile.bionic does not npm install playwright globally.
I ran this script:
const playwright = require('playwright'); (async () => { for (const browserType of ['chromium', 'firefox', 'webkit']) { const browser = await playwright[browserType].launch({headless: true, args: ['--no-sandbox']}); const context = await browser.newContext(); const page = await context.newPage(); await page.goto('http://whatsmyuseragent.org/'); await page.screenshot({ path:
example-${browserType}.png}); await browser.close(); } })();
but I get error
Error: Cannot find module 'playwright'
Any help is much appreciated fellow coders.
The text was updated successfully, but these errors were encountered: