moon icon indicating copy to clipboard operation
moon copied to clipboard

File download and list API for Playwright

Open vania-pooh opened this issue 10 months ago • 4 comments

Need something similar to /download API in Selenium.

vania-pooh avatar Apr 03 '24 14:04 vania-pooh

This is critical for us too, since we are moving to playwright from Selenium C# and we don't have a way to recover the files from the pod.

facusantillo avatar Apr 03 '24 14:04 facusantillo

we need it as well, much needed to download files on playwright running on moon. download to f.e. /home/user/Downloads doesnt work (using robot framework with browser library (playwright)

keef78 avatar Jun 20 '24 21:06 keef78

const { chromium } = require('playwright');
  
(async () => {
  var browser = await chromium.connect({ timeout: 0, wsEndpoint: 'ws://moon.aerokube.local/playwright/chrome/playwright-1.46.1?headless=false' });
  const page = await browser.newPage();
  await page.goto('https://kernel.org/');

  const downloadPromise = page.waitForEvent('download');
  await page.getByRole('link', { name: '6.10.8' }).click();
  const download = await downloadPromise;

  await download.saveAs(download.suggestedFilename());
  await browser.close();
})();

https://playwright.dev/docs/downloads

vania-pooh avatar Sep 06 '24 08:09 vania-pooh

I am not sure I understand the comment, basically our issue is not with the download it self - file is downloaded - but it cannot be recovered from the "save as" lcoation - the lcoation is not available to the current running browser session - so in the case for example you download the PDF file as per documentation to "/home/user/Downloads/some.pdf" - https://aerokube.com/moon/latest/#accessing-downloaded-files , the session started by playwright cannot reach this destination. I have verified the access rights are ok..

but when we try to serve the files in advance to the browser session https://aerokube.com/moon/latest/#selenium-context - so during the start of the session browser is informed where are some file fot the test usage, like in /home/user/some.pdf , the browser session in playwright on Moon can open this file ..

keef78 avatar Sep 06 '24 08:09 keef78