mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test(downloads): add passing test for downloads and interception (#6586)
This commit is contained in:
parent
37d03e8b7b
commit
7bbb91f265
@ -469,4 +469,19 @@ it.describe('download event', () => {
|
|||||||
expect(data.equals(content)).toBe(true);
|
expect(data.equals(content)).toBe(true);
|
||||||
await page.close();
|
await page.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should report downloads with interception', async ({browser, server}) => {
|
||||||
|
const page = await browser.newPage({ acceptDownloads: true });
|
||||||
|
await page.route(/.*/, r => r.continue());
|
||||||
|
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||||
|
const [ download ] = await Promise.all([
|
||||||
|
page.waitForEvent('download'),
|
||||||
|
page.click('a')
|
||||||
|
]);
|
||||||
|
const path = await download.path();
|
||||||
|
expect(fs.existsSync(path)).toBeTruthy();
|
||||||
|
expect(fs.readFileSync(path).toString()).toBe('Hello world');
|
||||||
|
await page.close();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user