showing results for - "puppeter example fileupload"
Claire
07 Jul 2017
1const puppeteer = require('puppeteer')
2const path = require('path')
3const fs = require('fs')
4const pathFile = __dirname.split('\\').slice(0, 4).join('/')
5const fileExitst = fs.existsSync(`${pathFile}/travis_1.png`)
6
7const scraperRunner = async () => {
8	const browser = await puppeteer.launch({ headless: false, args: ['--no-sanbox'] })
9	const page = await browser.newPage()
10	await page.goto('https://anonfiles.com', { waitUntil: 'networkidle2' })
11
12	await page.waitForSelector('input[type="file"]')
13	const input = await page.$('input[type="file"]')
14	if (fileExitst) {
15		await input.uploadFile(`${pathFile}/travis_1.png`)
16	}
17}
18
19scraperRunner()