Created
August 17, 2017 08:53
-
-
Save mrtc0/6be4291a947cb70643f1becbd52b2185 to your computer and use it in GitHub Desktop.
puppeteerでalertをチェックするやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async() => { | |
const url = 'http://'; | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(url, {waitUntil: 'networkidle'}); | |
page.on('dialog', dialog => { | |
console.log(dialog.message()); | |
dialog.accept(); | |
}) | |
await page.focus('input'); | |
await page.type('<script>alert(1)</script>'); | |
// await page.type('Hello'); | |
await page.click('button'); | |
await page.waitForSelector('script'); | |
const result = await page.evaluate(() => { | |
return Promise.resolve(document.body.innerHTML); | |
}) | |
console.log(result); | |
browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment