-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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]: Tests running in Electron do not show snapshots in the timeline #31393
Labels
Comments
Debugging notes, while Electron integration into @playwright/test isn't fully there yet, #8208 I still experienced a bug around closing the Electron application:
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts
index 3fbaf3358..85f5883ef 100644
--- a/packages/playwright/src/index.ts
+++ b/packages/playwright/src/index.ts
@@ -597,7 +597,8 @@ class ArtifactsRecorder {
if ((tracing as any)[this._startedCollectingArtifacts])
return;
(tracing as any)[this._startedCollectingArtifacts] = true;
- if (this._testInfo._tracing.traceOptions())
+ // This was throwing because ElectronApplication closes the BrowserContext which disposes the APIRequestContext which triggers this via the instrumentation but we never started tracing before.
+ if (this._testInfo._tracing.traceOptions() && (tracing as any)[kTracingStarted])
await tracing.stopChunk({ path: this._testInfo._tracing.generateNextTraceRecordingPath() });
}
}
diff --git a/tests/page/wheel.spec.ts b/tests/page/wheel.spec.ts
index c8c634e16..87bf1a1bb 100644
--- a/tests/page/wheel.spec.ts
+++ b/tests/page/wheel.spec.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import type { Page } from 'playwright-core';
+import { _electron, type Page } from 'playwright-core';
import { test as it, expect, rafraf } from './pageTest';
it.skip(({ isAndroid }) => {
@@ -48,23 +48,29 @@ async function expectEvent(page: Page, expected: any) {
expect(received).toEqual(expected);
}
-it('should dispatch wheel events @smoke', async ({ page, server }) => {
- await page.setContent(`<div style="width: 5000px; height: 5000px;"></div>`);
- await page.mouse.move(50, 60);
- await listenForWheelEvents(page, 'div');
- await page.mouse.wheel(0, 100);
- await page.waitForFunction('window.scrollY === 100');
- await expectEvent(page, {
- deltaX: 0,
- deltaY: 100,
- clientX: 50,
- clientY: 60,
- deltaMode: 0,
- ctrlKey: false,
- shiftKey: false,
- altKey: false,
- metaKey: false,
- });
+const test = it;
+it('should dispatch wheel events @smoke', async ({ trace }) => {
+ const electronApp = await _electron.launch({ args: ['/Users/maxschmitt/Developer/playwright/tests/electron/electron-window-app.js'] });
+
+ // Get the first window that the app opens, wait if necessary.
+ const window = await electronApp.firstWindow();
+ if (trace)
+ await window.context().tracing.start({ screenshots: true, snapshots: true });
+
+ await window.goto('https://playwright.dev/');
+
+ // Expect a title "to contain" a substring.
+ await expect(window).toHaveTitle(/Playwright/);
+
+ if (trace) {
+ await window.context().tracing.stop({ path: test.info().outputPath('electron-trace.zip') });
+ test.info().attachments.push({
+ name: 'trace',
+ path: test.info().outputPath('electron-trace.zip'),
+ contentType: 'application/zip'
+ });
+ }
+ await electronApp.close();
});
it('should dispatch wheel events after context menu was opened', async ({ page, browserName, isWindows }) => {
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
1.44.1
Steps to reproduce
a. YARN:
yarn create playwright
b. NPM:
npm init playwright@latest
a. YARN:
yarn add -D electron
b. NPM:
npm install --save-dev electron
c. In my case, I installed version
v31.0.2
a. YARN:
yarn playwright test --ui
b. NPM:
npx playwright test --ui
example.spec.ts
test "has title"Code
./playwright.config.ts
./tests/example.spec.ts
./main.js
Expected behavior
I expect to see snapshots in the timeline of the trace viewer.
I expect the selected action to show a snapshot on "Action", "Before" and "After".
Actual behavior
I only see one blank snapshot at the start of the test, I do not see a snapshot of the page visited during the test (or any other action).
![image](https://private-user-images.githubusercontent.com/66309261/341381987-e96759c6-6562-43ac-9214-cdd44644aeee.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MTg4NzMsIm5iZiI6MTczOTQxODU3MywicGF0aCI6Ii82NjMwOTI2MS8zNDEzODE5ODctZTk2NzU5YzYtNjU2Mi00M2FjLTkyMTQtY2RkNDQ2NDRhZWVlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDAzNDkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4ZjE3NDNiMmQ2NDQwZTkxMDFkZDAwNTdjYTNkZWMxZmY0NDM4ZTY5OGI2Zjc0MGE2MDMzZmVhMjgyZjNjZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.9XqDSx_KXZaz8T1UbG0-TFhxQkSj2LQbDz1JREsC72c)
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: