Skip to content

(Question)Video Upload Succeeds via Manual UI, but Fails Silently via Playwright's setInputFiles #35876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sangamesh-m007 opened this issue May 7, 2025 · 1 comment

Comments

@Sangamesh-m007
Copy link

Sangamesh-m007 commented May 7, 2025

Hi

I'm trying to automate a video upload in a DSP platform using Playwright. When I upload the video manually via the UI, everything works — the video preview is shown and I can proceed. But when I try to upload it using setInputFiles, the test passes but the video never appears, and it seems like the upload doesn't actually go through (even though there's no error).

@Sangamesh-m007 Sangamesh-m007 changed the title Video Upload Succeeds via Manual UI, but Fails Silently via Playwright's setInputFiles (Question)Video Upload Succeeds via Manual UI, but Fails Silently via Playwright's setInputFiles May 7, 2025
@mxschmitt
Copy link
Member

mxschmitt commented May 7, 2025

The problem is that you are uploading videos with proprietary codecs and Chromium does not support mp4 with all the codecs. In the code itself, there is something like this:

const a = document.createElement("video");
a.onloadedmetadata = () => {
  // ...
}

there is on onerror handler tho which would yell if the video can't load, e.g. due to unsupported codecs.

I recommend reaching out to your developers to add such a handler and add appropriate error reporting.

To fix the tests, you can use channel: 'chrome' in your playwright.config.ts's use section. I also used Codegen to create a bit of a more reliable version of your test which follow our best-practises:

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

test('File Upload Test', async ({ page }) => {
  await page.goto('https://qa.alkimi-dsp.com/user/login');
  await page.getByRole('textbox', { name: 'Login' }).fill('admin@alkimi.org');
  await page.getByRole('textbox', { name: 'Password' }).fill('AlkimiPassw0rd!');
  await page.getByRole('button', { name: 'Log In' }).click();
  await page.getByRole('button', { name: 'Creatives' }).click();
  await page.getByRole('menuitem', { name: 'Creatives' }).click();
  await page.getByRole('link', { name: 'New Creative' }).click();
  await page.getByRole('button', { name: 'Select advertiser Select' }).click();
  await page.getByText('Advertiser-').click();
  await page.getByRole('button', { name: 'Creative details' }).click();
  await page.getByRole('textbox', { name: 'name' }).fill('Tester123');
  await page.locator('[id="Date\\ From"]').fill('2025-05-22');
  await page.getByRole('group').filter({ hasText: 'Date To*' }).getByRole('textbox').fill('2025-05-23');
  await page.getByRole('textbox', { name: 'landingUrl' }).fill('https://www.alkimi.org');
  await page.getByRole('button', { name: 'Dimensions Dimensions *' }).click();
  await page.getByText('1280x720').click();
  await page.getByText('Select a file or drop hereMP4, WEBM or OGG, file size no more than 10MBSelect').click();
  const waitForFileChooser = page.waitForEvent('filechooser');
  await page.getByText('Select File').click();
  const fileChooser = await waitForFileChooser;
  await fileChooser.setFiles('output.mp4');
  await expect(page.getByText('1280px x 720px')).toBeVisible();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants