While running the script throws cannot find module ‘dotenv’
You should check if dotenv is installed, otherwise type in terminal: npm install –save dotenv or dotenv-extended npm install –save dotenv-extended
You should check if dotenv is installed, otherwise type in terminal: npm install –save dotenv or dotenv-extended npm install –save dotenv-extended
I figured it out myself. Here’s the code. console.log(‘waiting for iframe with form to be ready.’); await page.waitForSelector(‘iframe’); console.log(‘iframe is ready. Loading iframe content’); const elementHandle = await page.$( ‘iframe[src=”https://example.com”]’, ); const frame = await elementHandle.contentFrame(); console.log(‘filling form in iframe’); await frame.type(‘#Name’, ‘Bob’, { delay: 100 });
The GitHub issue about capturing console erorrs includes a great comment about listening to console and network events. For example, you can register for console output and network responses and failures like this: page .on(‘console’, message => console.log(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`)) .on(‘pageerror’, ({ message }) => console.log(message)) .on(‘response’, response => console.log(`${response.status()} ${response.url()}`)) .on(‘requestfailed’, request => console.log(`${request.failure().errorText} … Read more
Puppeteer v0.13.0 has page.select() method, which does exactly that. You just have to give it the value to select. So, assuming you have an <option value=”my-value”> in your <select>: await page.select(‘#telCountryInput’, ‘my-value’)