Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active March 23, 2017 01:11
Show Gist options
  • Save kjunichi/010221af28559f60bae87ccd9b46554d to your computer and use it in GitHub Desktop.
Save kjunichi/010221af28559f60bae87ccd9b46554d to your computer and use it in GitHub Desktop.
Nightmareのメモ

ポップアップウィンドウをあつかうには

npm install nightmare-window-manager
const Nightmare = require('nightmare')
require('nightmare-window-manager')(Nightmare)
nightmare
    .windowManager()
    .viewport(1024, 768)
nightmare.goto(url)
.click("[name=\"button\"]")
.waitWindowLoad()
.currentWindow()
.then((window) => {
nightmare.evaluateWindow(() => {
return document.body.innerText
}).then((text) => {
console.log(text)
nightmare.closeWindow(window.id)
.wait(500)
.then(() => {
//
}).catch((e)=>{
console.log(`e = ${e}`)
// reject
})
}).catch((e) => {
console.log(`e = ${e}`)
// reject2
})
}).catch((e) => {
console.log(`e = ${e}`)
// reject
})

関連記事

アクセス解析タグ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment