node nightmare 网页自动化测试 sample

安装nightmare

编写1.js

运行 node 1.js

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);
});

你可能感兴趣的:(node nightmare 网页自动化测试 sample)