Skip to content

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

test: dialog.accept works in headless persistent context (#35955)

Yury Semikhatsky3ef9baa1d1df
diff --git a/tests/library/defaultbrowsercontext-2.spec.ts b/tests/library/defaultbrowsercontext-2.spec.ts
index f3f273724a..ea5de96322 100644
--- a/tests/library/defaultbrowsercontext-2.spec.ts
+++ b/tests/library/defaultbrowsercontext-2.spec.ts
@@ -253,3 +253,19 @@ it('user agent is up to date', async ({ launchPersistent, browser, mode }) => {
expect(await page.evaluate(() => navigator.userAgent)).toBe(userAgent);
await context.close();
});
+
+it('dialog.accept should work', {
+ annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35663' }
+}, async ({ launchPersistent, mode }) => {
+ it.skip(mode !== 'default');
+ const { context, page } = await launchPersistent();
+ await page.goto('data:text/html,<html><title>Title</title><button onclick="alert(\'Alert\')">Button</button></html>');
+ let shown = false;
+ page.on('dialog', dialog => {
+ shown = true;
+ void dialog.accept();
+ });
+ await page.getByRole('button', { name: 'Button' }).click();
+ expect(shown).toBe(true);
+ await context.close();
+});