I'm trying puppeteer and browserless/chrome (https://hub.docker.com/r/browserless/chrome) to test some automation scripts. I'm currently just running a browserless/chrome instance locally, connecting puppeteer to it with browserWSEndpoint.
It's all running locally, all in the same machine.
Everything pretty much works except the file upload code. Without the browserless connection (just launching puppeteer and a chromium instance) the code can upload the images without a problem, however, when relaying it to a the websocket, it apparently can't find the files, even if I supply the full path.
Here is the code i'm using:
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://localhost:32769',
headless: true
})
const page = await browser.newPage();
await page.goto('http://localhost:8080', {waitUntil: 'networkidle2'});
// Do some things
let testUpload = async () => {
const upload = await page.$("input");
await upload.uploadFile('test.jpg');
await page.screenshot({path: 'test_s_'+Date.now()+'.png'});
}
// Do more things
I'm 100% sure the DOM exists at that point, and that the file exists, in the same folder.
Any pointing in the right direction is very helpfull.
Cheers!
from Puppeteer & browserWSEndpoint: can't upload files dynamically
No comments:
Post a Comment