skip to Main Content

I have a playwright test that consists in uploading a file. The test passes under my local environment (Windows, Playwright 1.35.1 with up-to-date deps) on both projects (Chromium and Firefox)
Although, when launching the test on Gitlab CI, it passes for Chromium but fails for Firefox with the message "frame.setInputFiles: Target closed".
The CI job is using debian:11.7-slim docker image, and similarly, playwright 1.35.1 with up-to-date browsers and deps.

I tried the headless mode locally and the test still passes.
I also tried the fileChooser way on CI and it doesn’t make it any better.

I managed to make a code snippet to repro the error.

import { test, expect } from '@playwright/test';

test('test', async ({ page }) => {
  await page.goto('https://www.file.io/');
  await page.getByText('Upload Files').click();
  const fileInputElement = page.locator('#upload-button');
  await fileInputElement.setInputFiles('dummy.pdf');
});

Something I noticed, though: when launching the test locally (both in headless and headful mode):
On Chromium, the file browsing window doesn’t even show up but the file uploads.
On Firefox, the file browsing window shows up, and doesn’t disappear even after the file upload. It takes at least 10 seconds to disappear (the browser window has already disappeared at that point).

Thank you.

UPDATE: I updated Playwright to the latest release (1.43.1) and the problem persists.

2

Answers


  1. Chosen as BEST ANSWER

    I solved the issue. Not ideal, but by adding test.use({headless: false}); specifically in the test above, it now passes on CI.


  2. I run the test with test.use({headless: false}); but its says like thisenter image description here. Did you use xvfb-run or you can run the test on ci in another ways? Thanks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search