aerokube / moon

Browser automation solution for Kubernetes and Openshift supporting Selenium, Playwright, Puppeteer and Cypress
http://aerokube.com/moon/latest
Apache License 2.0
224 stars 20 forks source link

File download and list API for Playwright #417

Open vania-pooh opened 7 months ago

vania-pooh commented 7 months ago

Need something similar to /download API in Selenium.

facusantillo commented 7 months ago

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.

keef78 commented 4 months ago

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)

vania-pooh commented 2 months ago
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

keef78 commented 2 months ago

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 ..