puppeteer file upload example

Example: puppeter example fileupload

const puppeteer = require('puppeteer')
const path = require('path')
const fs = require('fs')
const pathFile = __dirname.split('\\').slice(0, 4).join('/')
const fileExitst = fs.existsSync(`${pathFile}/travis_1.png`)

const scraperRunner = async () => {
	const browser = await puppeteer.launch({ headless: false, args: ['--no-sanbox'] })
	const page = await browser.newPage()
	await page.goto('https://anonfiles.com', { waitUntil: 'networkidle2' })

	await page.waitForSelector('input[type="file"]')
	const input = await page.$('input[type="file"]')
	if (fileExitst) {
		await input.uploadFile(`${pathFile}/travis_1.png`)
	}
}

scraperRunner()