Skip to content

fix(electron): enable screenshot-on-failure for Electron apps#40058

Open
Glisa060 wants to merge 1 commit intomicrosoft:mainfrom
Glisa060:fix-electron-screenshot-on-failure
Open

fix(electron): enable screenshot-on-failure for Electron apps#40058
Glisa060 wants to merge 1 commit intomicrosoft:mainfrom
Glisa060:fix-electron-screenshot-on-failure

Conversation

@Glisa060
Copy link
Copy Markdown

@Glisa060 Glisa060 commented Apr 4, 2026

Summary

  • Track Electron apps in Playwright._electronApps so _allContexts() includes Electron contexts
  • Enables screenshot: 'only-on-failure' to capture Electron windows on test failure

Update

  • Squashed two commits into one
  • Removed runAfterCreateBrowserContext call that caused tracing conflicts with Electron contexts

cc: @pavelfeldman

@Glisa060
Copy link
Copy Markdown
Author

Glisa060 commented Apr 5, 2026

@Glisa060 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Test results for "tests 1"

9 failed
❌ [installation tests] › playwright-electron-should-work.spec.ts:44 › should work when wrapped inside @playwright/test and trace is enabled @package-installations-ubuntu-latest
❌ [installation tests] › playwright-electron-should-work.spec.ts:44 › should work when wrapped inside @playwright/test and trace is enabled @package-installations-windows-latest
❌ [installation tests] › playwright-electron-should-work.spec.ts:44 › should work when wrapped inside @playwright/test and trace is enabled @package-installations-macos-latest
❌ [chromium-library] › library/video.spec.ts:724 › screencast › should work with video+trace @chromium-ubuntu-22.04-node22
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node20
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @macos-latest-node20
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node24
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @ubuntu-latest-node22
❌ [playwright-test] › playwright.artifacts.spec.ts:619 › should work with screenshot: only-on-failure for electron @windows-latest-node20

4 flaky ⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:481 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/video.spec.ts:652 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`

39144 passed, 846 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Test results for "MCP"

6 failed
❌ [firefox] › mcp/sse.spec.ts:88 › sse transport browser lifecycle (isolated) @mcp-windows-latest
❌ [firefox] › mcp/sse.spec.ts:118 › sse transport browser lifecycle (isolated, multiclient) @mcp-windows-latest
❌ [firefox] › mcp/sse.spec.ts:168 › sse transport browser lifecycle (persistent, multiclient) @mcp-windows-latest
❌ [firefox] › mcp/sse.spec.ts:193 › sse transport browser lifecycle (persistent) @mcp-windows-latest
❌ [firefox] › mcp/sse.spec.ts:233 › sse transport shared context @mcp-windows-latest
❌ [msedge] › mcp/files.spec.ts:106 › clicking on download link emits download @mcp-windows-latest

6423 passed, 383 skipped


Merge workflow run.

@pavelfeldman
Copy link
Copy Markdown
Member

@Glisa060 Glisa060 force-pushed the fix-electron-screenshot-on-failure branch from 6b321b1 to 01a3540 Compare April 8, 2026 21:22
@Glisa060 Glisa060 force-pushed the fix-electron-screenshot-on-failure branch from 01a3540 to aaff8ba Compare April 8, 2026 21:22
@Glisa060
Copy link
Copy Markdown
Author

Glisa060 commented Apr 8, 2026

Failures seem related: https://mspwblobreport.z1.web.core.windows.net/run-23988844205-2-50b5779a1623959574965456eeb37e0ca02ea02a/index.html#?q=s%3Afailed

You are right

The test-failed-1.png wasn't generated because the old code's "runAfterCreateBrowserContext" call interfered with the screenshot capture lifecycle.

After the fix (removing that call), the test passes locally. New CI run, that will be the real confirmation.

My new commit fixes the 5 failing tests in playwright.artifacts.spec.ts.
The other spec file failures are pre-existing issues and are not related to my changes

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

Successfully merging this pull request may close these issues.

2 participants