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

Any Docs dedicated for playwright-core?[Question] #3099

Closed
dllmkdir opened this issue Jul 23, 2020 · 4 comments
Closed

Any Docs dedicated for playwright-core?[Question] #3099

dllmkdir opened this issue Jul 23, 2020 · 4 comments

Comments

@dllmkdir
Copy link

I would like to use playwright-core with a Custom Chromium version, but the implementation details are not very clear.
I dont know if playwright-core take instantly any installed version of Chromium in my system.
Also, I am not sure if I can create a .local-chromium/Chromium.app folder in node-modules/playwright and it will instantly take this by default.

This is my code:

import playwright from 'playwright-core'
let playwrightBrowser = playwright['chromium']
let browser = await playwrightBrowser.launch({
      headless,
      args: [
        '--disable-gpu',
        '--no-sandbox',
        '--single-process',
        '--disable-setuid-sandbox',
        '--disable-web-security',
        '--disable-dev-profile',
      ],
      executablePath:  '/Users/dllmkdir/Documents/Chromium.app',
    })

I got some errors when I run this:

TypeError: Cannot read property 'launch' of undefined

And when I use import playwright from 'playwright' this error shows up:

Error: Failed to launch browser: Error: spawn /Users/dllmkdir/Documents/Chromium.app EACCES

I am using MacOSX10.15.5 and playwright-core 1.2.1

@arjunattam
Copy link
Contributor

Thanks @dllmkdir. Can you help us understand your needs better? playwright-core is meant to be an implementation detail and we expect playwright and/or playwright-chromium to fulfill such needs. A few questions that I'd love your input on:

  • What is the motivation behind using a custom Chromium version?
  • Is there a reason behind preferring playwright-core over the playwright/playwright-chromium packages?

We should be able to suggest a solution based on your answers – and also update the docs. Thanks for your time!

The EACCES error with the playwright package seems indicate missing permissions. You could try chmod +x <path> to fix that.

@dllmkdir
Copy link
Author

dllmkdir commented Jul 23, 2020

@arjun27 of course.
The scenario is creating a standalone automation using playwright. The computer that will execute playwright CANT have node js installed, so I need to bundle my automation with all the browsers as executables(It is a requirement to have all the browsers). I have already figured out creating the executable for the node js app, using @zeit/pkg. But I don´t understand why I can´t specify a different browser to playwright.

The reason of using playwright-core is because if I need to bundle the chromium, firefox and safari executables there is no need to use the complete playwright because I will need to specify the executablePath or the browser always. I will not be able to install playwright using yarn add playwright in 20 computers to only install the browsers !

The desired escenario could be bundling all this folders in a zip:

---exe.zip
   |_______ playwright
          ...... |_______ ...playwright contents
          ...... |_______ .local-chromium/Chromium.app
          ...... |_______ .local-firefox/Nightly.app
   |_______ myexe.exe

also, myexe.exe is already able to point to the external playwright module. The reason to do this is because pkg is not able to bundle the playwright browser executables.

EACCES Error still appears even after executing the chmod +x '/Users/dllmkdir/Documents/Chromium.app'
This is what I got if I run ls -la

drwxr-xr-x   3 dllmkdir  staff       96 Jul 22 18:27 Chromium.app

For the test I am making, The procedure to extract the current Chromium.app from playwright was going to the following path:

Users/dllmkdir/Library/Caches/ms-playwright/chromium-782078/chrome-mac/Chromium.app
and I copied the browser that was here to my documents folder for testing purposes. This is the one that is giving me the EACCES problem.

@dgozman
Copy link
Contributor

dgozman commented Jul 24, 2020

@dllmkdir You might be interested in a similar discussion about bundling playwright with browsers in #2539.

@dllmkdir
Copy link
Author

Hey guys, I found the problem regarding to the executablePath property.
OSX .app bundlings are folders and the real executable is inside them. I never understood what went wrong with playwright-core library, but my solution was creating a dynamic executablePath function.

Here is the fix for executablePath for macOSX:

import playwright from 'playwright'
let playwrightBrowser = playwright['chromium']
let browser = await playwrightBrowser.launch({
      headless,
      args: [
        '--disable-gpu',
        '--no-sandbox',
        '--single-process',
        '--disable-setuid-sandbox',
        '--disable-web-security',
        '--disable-dev-profile',
      ],
//point to executable not to .app folder
      executablePath:  '/Users/dllmkdir/Documents/Chromium.app/Contents/MacOS/Chromium',
    })

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

3 participants