我想在我的剧本中多次拨打casper.start()
。
我试过了:
var ids = [1,6,13];
ids.forEach(function(id) {
casper.start('http://localhost/mypage?id='+id, function() { });
});
casper.then(function() {
....
但是,只有最后一个id被执行。
可以多次拨打casper.start()
吗?如果是这样,怎么样?
答案 0 :(得分:4)
start()
对象调用{p> casper
。您只看到一个呼叫,因为对start()
的第二次呼叫会重置内部状态。您可以使用thenOpen()
打开多个页面:
var ids = [1,6,13];
casper.start();
ids.forEach(function(id) {
casper.thenOpen('http://localhost/mypage?id='+id, function() {
this.capture("id.png");
});
});
casper.run();