Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: fix/unflake/rebase some tests (#38508)

Dmitry Gozman39bb2ccc4657
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index c7c7fde49f..e5b2cb54b3 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -241,18 +241,19 @@ it('window.GestureEvent in WebKit', async ({ page, server, browserName }) => {
expect(type).toBe(browserName === 'webkit' ? 'function' : 'undefined');
});
-it('requestFullscreen', async ({ page, server }) => {
+it('requestFullscreen', async ({ page, server, browserName, headless }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22832' });
+ it.fixme(browserName === 'firefox' && !headless, 'Error: Request for fullscreen was denied because requesting element is not in the currently focused tab');
await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => {
const result = new Promise(resolve => document.addEventListener('fullscreenchange', resolve));
- void document.documentElement.requestFullscreen();
+ void document.documentElement.requestFullscreen().then(() => console.log('success')).catch(e => console.log(e));
return result;
});
expect(await page.evaluate(() => document.fullscreenElement === document.documentElement)).toBeTruthy();
await page.evaluate(() => {
const result = new Promise(resolve => document.addEventListener('fullscreenchange', resolve));
- void document.exitFullscreen();
+ void document.exitFullscreen().then(() => console.log('success')).catch(e => console.log(e));
return result;
});
expect(await page.evaluate(() => !!document.fullscreenElement)).toBeFalsy();
diff --git a/tests/library/chromium/tracing.spec.ts b/tests/library/chromium/tracing.spec.ts
index 9a39774fb6..fad85c3415 100644
--- a/tests/library/chromium/tracing.spec.ts
+++ b/tests/library/chromium/tracing.spec.ts
@@ -100,7 +100,7 @@ it('should support a buffer without a path', async ({ browser, server }) => {
const page = await browser.newPage();
await browser.startTracing(page, { screenshots: true });
await page.goto(server.PREFIX + '/grid.html');
- await rafraf(page);
+ await rafraf(page, 100);
const trace = await browser.stopTracing();
expect(trace.toString().includes('screenshot')).toBe(true);
await page.close();
diff --git a/tests/library/emulation-focus.spec.ts b/tests/library/emulation-focus.spec.ts
index 1b3a89f039..a7e71a6195 100644
--- a/tests/library/emulation-focus.spec.ts
+++ b/tests/library/emulation-focus.spec.ts
@@ -105,7 +105,6 @@ it('should not affect screenshots', async ({ page, server, browserName, headless
it.skip(browserName === 'webkit' && isWindows && !headless, 'WebKit/Windows/headed has a larger minimal viewport. See https://github.com/microsoft/playwright/issues/22616');
it.skip(browserName === 'webkit' && isLinux && !headless, 'WebKit headed has a larger minimal viewport on gtk4.');
it.skip(browserName === 'firefox' && !headless, 'Firefox headed produces a different image');
- it.fixme(browserName === 'chromium' && !isHeadlessShell && channel !== 'chromium-tip-of-tree', 'https://github.com/microsoft/playwright/issues/33330');
const page2 = await page.context().newPage();
await Promise.all([
diff --git a/tests/library/hit-target.spec.ts b/tests/library/hit-target.spec.ts
index 19578b8e62..d18915a1a8 100644
--- a/tests/library/hit-target.spec.ts
+++ b/tests/library/hit-target.spec.ts
@@ -251,7 +251,7 @@ it('should not click iframe overlaying the target', async ({ page, server }) =>
<iframe srcdoc="<body onclick='window.top._clicked=2' style='background-color:red;height:40px;'></body>" style="display: block; border: 0px; width: 100vw; height: 48px;"></iframe>
</div>
`);
- const error = await page.click('text=click-me', { timeout: 1000 }).catch(e => e);
+ const error = await page.click('text=click-me', { timeout: 3000 }).catch(e => e);
expect(await page.evaluate('window._clicked')).toBe(undefined);
expect(error.message).toContain(`<iframe srcdoc=\"<body onclick='window.top._clicked=2' style='background-color:red;height:40px;'></body>\"></iframe> from <div>…</div> subtree intercepts pointer events`);
});
diff --git a/tests/library/inspector/cli-codegen-1.spec.ts b/tests/library/inspector/cli-codegen-1.spec.ts
index 40ac0f9569..ae2a6f5299 100644
--- a/tests/library/inspector/cli-codegen-1.spec.ts
+++ b/tests/library/inspector/cli-codegen-1.spec.ts
@@ -91,7 +91,9 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync()
]);
});
- test('should click twice', async ({ openRecorder }) => {
+ test('should click twice', async ({ openRecorder, headless }) => {
+ test.skip(!headless, 'real mouse moves sneak between two clicks, moving away from the button');
+
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<button onclick="console.log('click')">Submit</button>`);
diff --git a/tests/library/screenshot.spec.ts b/tests/library/screenshot.spec.ts
index 6d2e9ecbba..cbf2f8dea8 100644
--- a/tests/library/screenshot.spec.ts
+++ b/tests/library/screenshot.spec.ts
@@ -23,8 +23,6 @@ browserTest.describe('page screenshot', () => {
browserTest.skip(({ browserName, headless }) => browserName === 'firefox' && !headless, 'Firefox headed produces a different image.');
browserTest('should run in parallel in multiple pages', async ({ server, contextFactory, browserName, isHeadlessShell, channel }) => {
- browserTest.fixme(browserName === 'chromium' && !isHeadlessShell && channel !== 'chromium-tip-of-tree', 'https://github.com/microsoft/playwright/issues/33330');
-
const context = await contextFactory();
const N = 5;
const pages = await Promise.all(Array(N).fill(0).map(async () => {
diff --git a/tests/page/page-event-request.spec.ts b/tests/page/page-event-request.spec.ts
index bf7643f0c2..25079a6306 100644
--- a/tests/page/page-event-request.spec.ts
+++ b/tests/page/page-event-request.spec.ts
@@ -182,13 +182,18 @@ it('should report navigation requests and responses handled by service worker wi
it('should return response body when Cross-Origin-Opener-Policy is set', async ({ page, server, browserName }) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
- res.end('Hello there!');
+ // Note: without 'onload', Firefox sometimes does not fire the load event
+ // over the protocol. The reason is unclear.
+ res.end(`
+ <div>Hello there!</div>
+ <script>window.onload = () => console.log('onload')</script>
+ `);
});
const response = await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);
await response.finished();
expect(response.request().failure()).toBeNull();
- expect(await response.text()).toBe('Hello there!');
+ expect(await response.text()).toContain('Hello there!');
});
it('should fire requestfailed when intercepting race', async ({ page, server, browserName }) => {
diff --git a/tests/page/page-goto.spec.ts b/tests/page/page-goto.spec.ts
index 2ef8e60bb2..1ea1264fa8 100644
--- a/tests/page/page-goto.spec.ts
+++ b/tests/page/page-goto.spec.ts
@@ -83,7 +83,12 @@ it('should work with cross-process that fails before committing', async ({ page,
it('should work with Cross-Origin-Opener-Policy', async ({ page, server }) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
- res.end();
+ // Note: without 'onload', Firefox sometimes does not fire the load event
+ // over the protocol. The reason is unclear.
+ res.end(`
+ <div>Hello there!</div>
+ <script>window.onload = () => console.log('onload')</script>
+ `);
});
const requests = new Set();
const events = [];
diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts
index 1edf5c6158..ed37bba3ac 100644
--- a/tests/playwright-test/test-step.spec.ts
+++ b/tests/playwright-test/test-step.spec.ts
@@ -657,9 +657,9 @@ test('should show final toPass error', async ({ runInlineTest }) => {
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('fail', async () => {
- await expect(() => {
+ await expect(async () => {
expect(true).toBe(false);
- }).toPass({ timeout: 1 });
+ }).toPass({ timeout: 2000, intervals: [10000] });
});
`
}, { reporter: '' });