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 test for downloads in nested downloads (#9924)
Max Schmittff8494c7e3a1
diff --git a/tests/download.spec.ts b/tests/download.spec.tsindex f8e7abaa10..5271dacfb3 100644--- a/tests/download.spec.ts+++ b/tests/download.spec.ts@@ -568,6 +568,36 @@ it.describe('download event', () => {expect(fs.readFileSync(path).toString()).toBe('Hello world');await page.close();});++ it('should emit download event from nested iframes', async ({ server, browser, browserName }, testInfo) => {+ it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/9922');+ const page = await browser.newPage({ acceptDownloads: true });+ server.setRoute('/1', (req, res) => {+ res.setHeader('Content-Type', 'text/html');+ res.end(`<iframe src="${server.PREFIX}/2"></iframe>`);+ });+ server.setRoute('/2', (req, res) => {+ res.setHeader('Content-Type', 'text/html');+ res.end(`<iframe src="${server.PREFIX}/3"></iframe>`);+ });+ server.setRoute('/3', (req, res) => {+ res.setHeader('Content-Type', 'text/html');+ res.end(` <a href="${server.PREFIX}/download">download</a>`);+ });+ await page.goto(server.PREFIX + '/1');++ const [download] = await Promise.all([+ page.waitForEvent('download'),+ page.frame({+ url: server.PREFIX + '/3'+ }).click('text=download')+ ]);+ const userPath = testInfo.outputPath('download.txt');+ await download.saveAs(userPath);+ expect(fs.existsSync(userPath)).toBeTruthy();+ expect(fs.readFileSync(userPath).toString()).toBe('Hello world');+ await page.close();+ });});it('should be able to download a PDF file', async ({ browser, server, asset }) => {