node nightmare 网页自动化测试 sample
生活随笔
收集整理的這篇文章主要介紹了
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);
});
轉載于:https://www.cnblogs.com/cutepig/p/5656461.html
總結
以上是生活随笔為你收集整理的node nightmare 网页自动化测试 sample的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Node中使用mysql模块遇到的问题
- 下一篇: 华为机试题【9】-整数分割为2的幂次