Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test(focus): add passing test for focusing more than one page (#4347)
Joel Einbinder3f37d8507e54
diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.tsindex 30bdd1efd9..75d9b1abba 100644--- a/test/emulation-focus.spec.ts+++ b/test/emulation-focus.spec.ts@@ -171,3 +171,15 @@ it('should change focused iframe', async ({page, server}) => {expect(focused).toEqual([false, true]);}});++// @see https://github.com/microsoft/playwright/issues/3476+it('should focus with more than one page/context', async ({contextFactory}) => {+ const page1 = await (await contextFactory()).newPage();+ const page2 = await (await contextFactory()).newPage();+ await page1.setContent(`<button id="foo" onfocus="window.gotFocus=true">foo</button>`);+ await page2.setContent(`<button id="foo" onfocus="window.gotFocus=true">foo</button>`);+ await page1.focus('#foo');+ await page2.focus('#foo');+ expect(await page1.evaluate(() => !!window['gotFocus'])).toBe(true);+ expect(await page2.evaluate(() => !!window['gotFocus'])).toBe(true);+});