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 more tests for reload (#21296)
Andrey Lushnikov4d3b056f278f
diff --git a/tests/page/page-history.spec.ts b/tests/page/page-history.spec.tsindex 2d04c54ac6..b5083fe0a6 100644--- a/tests/page/page-history.spec.ts+++ b/tests/page/page-history.spec.ts@@ -267,3 +267,30 @@ it('regression test for issue 20791', async ({ page, server }) => {await page.reload();await expect.poll(() => messages).toEqual(['foo', 'foo']);});++it('should reload proper page', async ({ page, server }) => {+ let mainRequest = 0, popupRequest = 0;+ server.setRoute('/main.html', (req, res) => {+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });+ res.end(`<!doctype html><h1>main: ${++mainRequest}</h1>`);+ });+ server.setRoute('/popup.html', (req, res) => {+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });+ res.end(`<!doctype html><h1>popup: ${++popupRequest}</h1>`);+ });+ await page.goto(server.PREFIX + '/main.html');+ const [popup] = await Promise.all([+ page.waitForEvent('popup'),+ page.evaluate(() => window.open('/popup.html')),+ ]);+ await expect(page.locator('h1')).toHaveText('main: 1');+ await expect(popup.locator('h1')).toHaveText('popup: 1');++ await page.reload();+ await expect(page.locator('h1')).toHaveText('main: 2');+ await expect(popup.locator('h1')).toHaveText('popup: 1');++ await popup.reload();+ await expect(page.locator('h1')).toHaveText('main: 2');+ await expect(popup.locator('h1')).toHaveText('popup: 2');+});