playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Electron: Playwright specific arguments between executable and project path

Open c3er opened this issue 2 years ago • 5 comments

System info

  • Playwright Version: [v1.34.3]
  • Operating System: observed on Windows 11
  • Browser: Electron
  • Other info: Regression of #16614 and #16782. See also this comment and this comment (and below). It seems to be introduced by commit 5c530154f926c22d991fb60e0dfa0b6cb3d9a275 but I didn't found any useful information in the referenced PR #18822

Source code

  • [ ] I provided exact source code that allows reproducing the issue locally.
const electronPath = require("electron")
const playwright = require("playwright")

const electron = playwright._electron

// ...

const app = await electron.launch({
    args: [
        "path/to/main.js",
        "path/to/my/file",
    ],
    executablePath: electronPath,
})

Expected

Given, the code above, process.argv should look like this:

[
    'path/to/Electron',
    'path/to/project',
    'path/to/my/file',
    '--inspect=0',
    '--remote-debugging-port=0',
]

Actual

process.argv looks like this:

[
    'path/to/Electron',
    '--inspect=0',
    '--remote-debugging-port=0',
    'path/to/project',
    'path/to/my/file',
]

c3er avatar May 31 '23 02:05 c3er

Any movement on this? Forcing user args to the end is breaking playwright testing for AppImages in docker containers on linux machines.

Expected

[
    'App-0.0.0-dev.AppImage'
    '--appimage-extract-and-run',
    '--no-sandbox'
]

Actual

    'App-0.0.0-dev.AppImage'
    '--inspect=0',
    '--remote-debugging-port=0',
    '--appimage-extract-and-run',
    '--no-sandbox'

Appending --appimage-extract-and-run at the end results in the following error.

Error

dlopen(): error loading libfuse.so.2

AppImages require FUSE to run. 
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information

jonmunozshieldai avatar Jun 03 '25 22:06 jonmunozshieldai

Well, if anyone also runs into the same issue, there's an environment variable which can be set to circumvent the prepending arguments bug.

export APPIMAGE_EXTRACT_AND_RUN=1

jonmunozshieldai avatar Jun 03 '25 23:06 jonmunozshieldai

I have the same issue when using Playwright to launch my Electron app.

// Expected argv
 [
'/my/electron/executable',
'/myapp/resources/app.asar/.webpack/main',
'--remote-debugging-port=0',
'--inspect=0',
'--custom-flag=foobar'
]

// Actual argv
 [
'/my/electron/executable',
'--inspect=0',
'--remote-debugging-port=0',
'/myapp/resources/app.asar/.webpack/main',
'--custom-flag=foobar'
]

My current workaround is to reorder the arguments if the --inspect flag is given to my app.

hug0b avatar Jun 04 '25 08:06 hug0b

My current workaround is to reorder the arguments if the --inspect flag is given to my app.

My workaround is to filter out the argument that starts with --inspect before the argument list hits the parsing logic.

See my commit for that.

c3er avatar Jun 04 '25 15:06 c3er

Any possible movement on this?

Nantris avatar Nov 10 '25 22:11 Nantris