Skip to content

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

test: fix recorder downloads test (#5454)

Pavel Feldman0782b25272c0
diff --git a/src/server/supplements/recorder/codeGenerator.ts b/src/server/supplements/recorder/codeGenerator.ts
index 8d8def14be..31872c2ed9 100644
--- a/src/server/supplements/recorder/codeGenerator.ts
+++ b/src/server/supplements/recorder/codeGenerator.ts
@@ -135,6 +135,11 @@ export class CodeGenerator {
return;
}
if (this._lastAction && !this._lastAction.committed) {
+ const signals = this._lastAction.action.signals;
+ if (signal.name === 'navigation' && signals.length && signals[signals.length - 1].name === 'download')
+ return;
+ if (signal.name === 'download' && signals.length && signals[signals.length - 1].name === 'navigation')
+ signals.length = signals.length - 1;
this._lastAction.action.signals.push(signal);
this._printAction(this._lastAction, true);
return;
diff --git a/test/cli/cli-codegen-2.spec.ts b/test/cli/cli-codegen-2.spec.ts
index 25398262b7..d6e1574027 100644
--- a/test/cli/cli-codegen-2.spec.ts
+++ b/test/cli/cli-codegen-2.spec.ts
@@ -110,9 +110,7 @@ describe('cli codegen', (suite, { mode, browserName, headful }) => {
await page.setInputFiles('input[type="file"]', []);`);
});
- it('should download files', (test, {browserName, headful}) => {
- test.fixme(browserName === 'webkit' || browserName === 'firefox', 'Generated page.waitForNavigation next to page.waitForEvent(download)');
- }, async ({ page, recorder, httpServer }) => {
+ it('should download files', async ({ page, recorder, httpServer }) => {
httpServer.setHandler((req: http.IncomingMessage, res: http.ServerResponse) => {
const pathName = url.parse(req.url!).path;
if (pathName === '/download') {