Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Getting chromium as undefined with playwright-core #2905

Closed
sudhakar3697 opened this issue Jul 10, 2020 · 6 comments
Closed

[BUG] Getting chromium as undefined with playwright-core #2905

sudhakar3697 opened this issue Jul 10, 2020 · 6 comments

Comments

@sudhakar3697
Copy link

Context:

  • Playwright Version: [playwright-core -v1.2.0]
  • Operating System: [Windows (Pro 10 - 1809) & Linux (Ubuntu 20.04)]
  • Node version: [v14.4.0 on Windows, v12.18.0 on Linux (Ubuntu 20.04)]
  • Browser: [Chromium]

Code Snippet

const { chromium } = require('playwright-core');

(async () => {
    try {
        const browser = await chromium.launch({
            headless: false,
            executablePath: 'c:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('http://whatsmyuseragent.org/');
        // await browser.close();
    } catch (err) {
        console.log(err);
    }
})();

Describe the bug
Getting chromium as undefined

TypeError: Cannot read property 'launch' of undefined
    at C:\Users\Sudhakar_r_r\Desktop\test-playwright\index.js:5:40
    at Object.<anonymous> (C:\Users\Sudhakar_r_r\Desktop\test-playwright\index.js:16:3)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
@mxschmitt
Copy link
Member

Hi, I agree. Especially when you want to use other Chromium related browsers like Microsoft Edge, its useful to only install the wrapper instead of installing e.g. playwright-chromium or whole playwright.
Workaround would be to use playwight-chromium for now.

@pavelfeldman
Copy link
Member

pavelfeldman commented Jul 12, 2020

playwright-core is an implementation detail of playwright. If you'd like Playwright that does not download the browsers, use skip environment variable as described in https://playwright.dev/#version=v1.2.0&path=docs%2Finstallation.md&q=skip-browser-downloads. If your use case makes you depend on playwright-core in NPM, we would love to learn why!

@coolgk
Copy link

coolgk commented Jul 13, 2020

My use case is for WSL, puppeteer-core works with launch options below. playwright basically doesn't work at all in wsl, since this is a Microsoft backed package, WSL support ideally should be prioritised (without the puppeteer workaround config below). I like the high-level utility functions and the great documentation of playwright but it doesn't work in WSL, I even use playwright documentation page as puppeteer tutorials.

  const windowsWSLWorkaround: LaunchOptions = {
    executablePath: '/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
    userDataDir: '/tmp/puppeteer',
    headless: false
  };
``

@pavelfeldman
Copy link
Member

Same options would work with playwright, could you elaborate on doesn't work at all in wsl?

@tyrak
Copy link

tyrak commented Jul 17, 2020

We are developing (and running) a "desktop application" (think of something akin to the carlo architecture) using puppeteer. For various reasons we have made the decision to use the system-wide installation of chromium.

Controlling whether playwright downloads chromium with an environment variable is not very ergonomic: we have to set the variable in every dev box and in every box where we deploy our app; developers have to remember to do PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install instead of npm install (and similarly for npm update).

In general, the reason why package.json and package-lock.json are great is because you can record in them various decisions you have made (e.g. about your dependencies) without having to communicate them to other developers verbally or through documentation. These decisions then propagate to all boxes automatically. They are even versioned! Git remembers when you made changes to them. This lessens the cognitive load of working with the system.

In our current implementation, we have solved the issue of how to signify that we don't want to use the bundled browser by specifying puppeter-core as a dependency instead of puppeter. It would be great if playwright provided a similar solution. I don't know if this is the right issue to discuss this, if not, I can open a new one.

@aslushnikov
Copy link
Collaborator

This is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants