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] Error: Failed to launch browser: Error: spawn ...chrome.exe ENOENT #2264

Closed
davidgilbertson opened this issue May 16, 2020 · 1 comment

Comments

@davidgilbertson
Copy link
Contributor

Context:

  • Playwright Version: 1.0.2
  • Operating System: Windows 10
  • Node version: 13.12, 14.0, 14.2
  • Browser: All

Code Snippet

Using the snippet from getting started:

const { chromium, firefox, webkit } = require('playwright');

(async () => {
  try {
    const browser = await chromium.launch();
    // const browser = await firefox.launch();
    // const browser = await webkit.launch();
    const page = await browser.newPage();
    await page.goto('http://whatsmyuseragent.org/');
    await page.screenshot({ path: `example.png` });
    await browser.close();
  } catch (err) {
    console.error(err);
  }
})();

Describe the bug
In an existing project (that had Cypress installed, not sure if that's relevant), I ran npm i playwright (in Windows Terminal/PowerShell), then ran npm audit fix (I got distracted) and noticed that Cypress re-ran some things. Then I ran the snippet above, and it failed for all three browsers.

I uninstalled Cypress, deleted package-lock.json and node_modules and ran npm i again. Still all three failed. I switched from Node 14.0 to 13.12 (using nvm windows, if that's relevant) and tried again, all three failed, switched to Node 14.2 and now webkit and firefox work (although I admit I'm maybe changing more than one variable between attempts).

My directory C:\Users\david\AppData\Local\ms-playwright\chromium-764964\chrome-win contains only a single file, 84.0.4135.0.manifest. Its contents are:

<assembly
  xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <assemblyIdentity
      name='84.0.4135.0'
      version='84.0.4135.0'
      type='win32'/>
  <file name='chrome_elf.dll'/>
</assembly>

I have Chrome and Chrome Canary (and Edge and Edge Canary) installed on my machine, not sure if that makes a difference.

With Node 14.2 I created a brand new project, installed only playwright, and it failed for chromium but works for firefox and webkit.

Then I deleted C:\Users\david\AppData\Local\ms-playwright and started all over again with Node 14.2 and everything worked. This seems to indicate that during install something is checking if the ms-playwright directory is there, but not checking that its contents are correct.

Lastly, I went back to how (I thought) I started out. Node 13.2, deleted C:\Users\david\AppData\Local\ms-playwright, and ran npm i playwright again and everything worked fine. So after all that I can't pinpoint a specific scenario, but hopefully some of the above is useful in ironing out install kinks.

May I suggest that when running, you check that the correct assets are available and install them if necessary?

Maybe this is a duplicate of #1992 or #1988 or #1085, but they seem different enough that I'll create this as a new issue.

@aslushnikov
Copy link
Contributor

@davidgilbertson hey David, thanks for filing.

This is due to #1988. Due to a node bug, Playwright downloading under Node 14.0 resulted in corrupted browsers, so once you switched to node 13.2 and re-downloaded browsers, everything was working.

In general, Node 14.1 and Node 14.2 are both working fine.

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

2 participants