我试图从Drupal站点上的两个网页拉标题标签文本。我想用Nightmarejs。Nightmarejs在同一测试中的多个页面
这是到目前为止我的代码:
// get the <title> text from inside the Drupal site
var Nightmare = require('nightmare');
var user = '[email protected]';
var pass = 'foobar';
new Nightmare()
.goto('http://example.com/user')
.type('#edit-name', user)
.type('#edit-pass', pass)
.click('.searchsubmit')
.wait()
.evaluate(function() {
return document.getElementsByTagName("TITLE")[0];
}, function (res) {
console.log('Homepage title: '+res.text);
})
.run(function(err, nightmare){
console.log('Done1.');
// step 2
nightmare
.goto('http://example.com/admin')
.wait()
.evaluate(function() {
return document.getElementsByTagName("TITLE")[0];
}, function (res) {
console.log('Admin page title: '+res.text);
})
.run(function(err, nightmare){
console.log('Done2.');
})
;
})
;
当我运行此,有:节点app.js我能够成功登录到第一页。不幸的是,当我尝试打开第二页时,我看到第二页呼叫拒绝访问(http://example.com/admin)。会议没有被带入第二个“goto”命令。
我能做些什么来打开同一个nightmarejs会话的许多页面?
工程就像一个魅力 – Sunjalo 2015-08-21 08:42:45