Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add file upload test case with popup handling (#29937)

Max Schmitt93dc89fa1f53
diff --git a/tests/page/page-set-input-files.spec.ts b/tests/page/page-set-input-files.spec.ts
index 966459a2c9..b43239596c 100644
--- a/tests/page/page-set-input-files.spec.ts
+++ b/tests/page/page-set-input-files.spec.ts
@@ -37,6 +37,23 @@ it('should upload the file', async ({ page, server, asset }) => {
}, input)).toBe('contents of the file');
});
+it('should upload a file after popup', async ({ page, server, asset, browserName }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29923' });
+ it.fixme(browserName === 'firefox');
+ await page.goto(server.PREFIX + '/input/fileupload.html');
+ {
+ const [popup] = await Promise.all([
+ page.waitForEvent('popup'),
+ page.evaluate(() => window['__popup'] = window.open('about:blank')),
+ ]);
+ await popup.close();
+ }
+ const filePath = path.relative(process.cwd(), asset('file-to-upload.txt'));
+ const input = await page.$('input');
+ await input.setInputFiles(filePath);
+ expect(await page.evaluate(e => e.files[0].name, input)).toBe('file-to-upload.txt');
+});
+
it('should upload large file', async ({ page, server, browserName, isMac, isAndroid, isWebView2, mode }, testInfo) => {
it.skip(browserName === 'webkit' && isMac && parseInt(os.release(), 10) < 20, 'WebKit for macOS 10.15 is frozen and does not have corresponding protocol features.');
it.skip(isAndroid);