Skip to content

[Question] how to run playwright script in docker #2972

@zammew

Description

@zammew

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions