nightmare
Version:
A high-level browser automation library.
21 lines (18 loc) • 525 B
JavaScript
/* eslint-disable no-console */
var Nightmare = require('nightmare')
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('form[action*="/search"] [name=p]', 'github nightmare')
.click('form[action*="/search"] [type=submit]')
.wait('#main')
.evaluate(function() {
return document.querySelector('#main .searchCenterMiddle li a').href
})
.end()
.then(function(result) {
console.log(result)
})
.catch(function(error) {
console.error('Search failed:', error)
})