我想使用Nightmare JS通過檢查狀態碼200來確定頁面是否正在加載。我查看了goto選項,但一直未能弄清楚。有人有主意嗎?Nightmare JS返回頁面狀態碼
var Nightmare = require('nightmare');
var should = require('chai').should();
describe('PageLoad Test', function() {
var url = 'http://www.yahoo.com';
describe('Browse Page', function() {
it('should return 200 status', function (done) {
this.timeout(15000);
new Nightmare()
.goto(url)
.wait(1000)
.evaluate(function() {
return document.querySelector('div.items').innerHTML;
})
.then(function (element) {
element.should.equal(element);
done();
})
.catch(function (error) {
console.error('page failed to load', error);
done('epic failure')
})
});
});
});
這也行,謝謝! –