Puppeteer: Inserting into a dialog with prompt? (Question)

Created on 5 Sep 2017  路  3Comments  路  Source: puppeteer/puppeteer

Hey, I would like to insert some data into a JS prompt like this one. Is that possible with puppeteer?
Thanks 馃槑

Most helpful comment

There's a snippet in the API: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-dialog

const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
  const page = await browser.newPage();
  page.on('dialog', async dialog => {
    console.log(dialog.message());
    await dialog.dismiss();
    browser.close();
  });
  page.evaluate(() => alert('1'));
});

All 3 comments

There's a snippet in the API: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-dialog

const puppeteer = require('puppeteer');

puppeteer.launch().then(async browser => {
  const page = await browser.newPage();
  page.on('dialog', async dialog => {
    console.log(dialog.message());
    await dialog.dismiss();
    browser.close();
  });
  page.evaluate(() => alert('1'));
});

@aslushnikov Thank you so much 馃槈

Was this page helpful?
0 / 5 - 0 ratings