Skip to content

Instantly share code, notes, and snippets.

@CodeLeom
Created October 24, 2023 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeLeom/bd4c7c17a0749044f7a1a9b606c3e5ae to your computer and use it in GitHub Desktop.
Save CodeLeom/bd4c7c17a0749044f7a1a9b606c3e5ae to your computer and use it in GitHub Desktop.
Automating a File Upload with Puppeteer
import puppeteer from "puppeteer";
// function to handle timeout
function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
await page.goto('https://easyupload.io/');
await page.waitForSelector('input[type=file]');
const inputUploadHandle = await page.$('input[type=file]');
await inputUploadHandle.uploadFile('./testdoc.pdf');
// There may be a submit button to finalize the resume submission.
await page.click('#upload');
// Introduce a delay if necessary
await delay(20000);
// Wait for a success message or acknowledgment.
await page.waitForSelector('.upload-success');
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment