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: add regression test for cross-context clicking (#29668)
Andrey Lushnikovb183159fd09f
diff --git a/tests/library/browsercontext-basic.spec.ts b/tests/library/browsercontext-basic.spec.tsindex 0fd1f98390..266eb80e1c 100644--- a/tests/library/browsercontext-basic.spec.ts+++ b/tests/library/browsercontext-basic.spec.ts@@ -31,6 +31,39 @@ it('should create new context @smoke', async function({ browser }) {expect(browser).toBe(context.browser());});+it('should be able to click across browser contexts', async function({ browser }) {+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29096' });+ expect(browser.contexts().length).toBe(0);++ const createPage = async () => {+ const page = await browser.newPage();+ await page.setContent(`<button>Click me</button>`);+ await page.locator('button').evaluate(button => {+ window['clicks'] = 0;+ button.addEventListener('click', () => ++window['clicks'], false);+ });+ return page;+ };++ const clickInPage = async (page, count) => {+ for (let i = 0; i < count; ++i)+ await page.locator('button').click();+ };++ const getClicks = async page => page.evaluate(() => window['clicks']);++ const page1 = await createPage();+ const page2 = await createPage();++ const CLICK_COUNT = 20;+ await Promise.all([+ clickInPage(page1, CLICK_COUNT),+ clickInPage(page2, CLICK_COUNT),+ ]);+ expect(await getClicks(page1)).toBe(CLICK_COUNT);+ expect(await getClicks(page2)).toBe(CLICK_COUNT);+});+it('window.open should use parent tab context', async function({ browser, server }) {const context = await browser.newContext();const page = await context.newPage();