microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.67k stars 3.65k forks source link

[Regression]: Playwright 1.44 cannot start Electron application with path contains spaces (Windows) #30755

Closed c3er closed 5 months ago

c3er commented 5 months ago

Version

1.44.0

Steps to reproduce

  1. Clone this repository https://github.com/c3er/electron-playwright-issue
  2. Install dependencies: npm install
  3. Run test: npm run test

Expected behavior

Test passes. If the test is executed on the desktop, the application window flickers.

Actual behavior

Test fails with this error message:

  Sample integration test
    1) "before all" hook for "opens a window"
    2) "after all" hook for "opens a window"

  0 passing (22ms)
  2 failing

  1) Sample integration test
       "before all" hook for "opens a window":
     electron.launch: Process failed to launch!
      at async startApp (test\integration.spec.js:10:17)
      at async Context.<anonymous> (test\integration.spec.js:26:39)

  2) Sample integration test
       "after all" hook for "opens a window":
     TypeError: Cannot read properties of null (reading 'close')
      at Context.<anonymous> (test\integration.spec.js:28:33)
      at process.processImmediate (node:internal/timers:478:21)
      at process.callbackTrampoline (node:internal/async_hooks:130:17)

Additional context

The same test works fine with Playwright 1.43.1. If you change the version in the package.json and reinstall the dependencies, the test passes.

The bug seems only to occur on Windows. On macOS, it works fine. I didn't try Linux.

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 47.42 GB / 63.90 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.89.1 - C:\Users\Christian\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 5.0.17 - C:\Windows\system32\bash.EXE
  npmPackages:
    playwright: 1.44.0 => 1.44.0
mxschmitt commented 5 months ago

I'm unfortunately not able to reproduce. I tried version 18 and latest 20, probably related to https://github.com/microsoft/playwright/commit/58187075c823a4f3751c0fc25e714077b0da7bdf.

Which Node.js version are you using on CI? Or are you reproducing it locally?

Could you set the $Env:DEBUG="pw:browser,pw:protocol" env var? This might yield more debug output when launching Electron with Playwright.

c3er commented 5 months ago

It appears to be actually a problem with space characters in the path, which would explain, why this didn't appear on my macOS.

Protocol of the last run:

D:\eigene dateien\devel\web\electron-playwright-issue [master ≡]> $Env:DEBUG="pw:browser,pw:protocol"
D:\eigene dateien\devel\web\electron-playwright-issue [master ≡]> npm test

> electron-playwright-issue@1.0.0 test
> mocha --timeout 20000

  Sample integration test
  pw:browser <launching> D:\eigene dateien\devel\web\electron-playwright-issue\node_modules\electron\dist\electron.exe --inspect=0 --remote-debugging-port=0 D:\eigene dateien\devel\web\electron-playwright-issue\app\main.js +0ms
  pw:browser <launched> pid=29208 +6ms
  pw:browser [pid=29208][err] Der Befehl "D:\eigene" ist entweder falsch geschrieben oder +2ms
  pw:browser [pid=29208][err] konnte nicht gefunden werden. +0ms
    1) "before all" hook for "opens a window"
  pw:browser [pid=29208] <process did exit: exitCode=1, signal=null> +3ms
  pw:browser [pid=29208] starting temporary directories cleanup +0ms
    2) "after all" hook for "opens a window"

  0 passing (21ms)
  2 failing

  1) Sample integration test
       "before all" hook for "opens a window":
     electron.launch: Process failed to launch!
      at async startApp (test\integration.spec.js:10:17)
      at async Context.<anonymous> (test\integration.spec.js:26:39)

  2) Sample integration test
       "after all" hook for "opens a window":
     TypeError: Cannot read properties of null (reading 'close')
      at Context.<anonymous> (test\integration.spec.js:28:33)
      at process.processImmediate (node:internal/timers:478:21)
      at process.callbackTrampoline (node:internal/async_hooks:130:17)

  pw:browser [pid=29208] finished temporary directories cleanup

The same project runs on a path without space characters just fine.

So, the regression is at handling space characters in the project's path.

mxschmitt commented 5 months ago

Note: this should be fixed in npm install -D @playwright/test@beta.

c3er commented 5 months ago

Note: this should be fixed in npm install -D @playwright/test@beta.

I can confirm, that the bug is fixed with version 1.44.1.