如果我们在没有 and 的情况下使用 casper--engine=slimerjs
则casper.scrollToBottom();
不起作用casper.page.scrollPosition = {top: scrollHeight, left: 0};
。
我的意思是,如果我们只使用$ casperjs file.js
它就行不通。但有了$ casperjs --engine=slimerjs file.js
它就足够了。
有什么建议吗?也许我应该在命令行中使用一些东西?喜欢--webdriver
?我试过--ssl-protocol=any
了——它也没有帮助。或者也许我应该包含 JS 文件,例如page.includeJs('https://www.my-site.com/thisjsfile.min.js')
PS:我不相信它会有帮助,但这里是代码:
casper.then(function() {
this.waitForSelector('#myselector', function() {
this.open('http://www.my-site.com/messages');
this.echo('Open messages Inbox');
});
})
.then(function() {
this.repeat(timesForCasperRepeat, function() {
this.wait(5000, function() {
scrollHeight = this.evaluate(function() {
return document.body.scrollHeight;
});
this.echo('Scroll Height: ' + scrollHeight);
this.scrollToBottom();
this.echo('scrolling down', 'INFO_BAR');
});
});
});
即使我scrollToBottom()
改为:
this.page.scrollPosition = {
top: scrollHeight,
left: 0
};
我还包括了 Anrtjom 的处理错误事件,有一个链接
我有错误:
Error: ReferenceError: Can't find variable: ourvarname1
Error: ReferenceError: Can't find variable: jQuery
Error: ReferenceError: Can't find variable: ourvarname2
Error: ReferenceError: Can't find variable: ourvarname3
Error: TypeError: 'undefined' is not a function (evaluating 'RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/)')
Console: Unsafe JavaScript attempt to access frame with URL http://www.my-site.com/messages from frame with URL http://ads.my-site.com/daisy?browser=windows_chrome&base=1&page=Mailbox&pageurl=%2fmessages&format=half_page&authid=1%2c0%2c1457605848%2c0xf290ca6243d86169%3beed7d0c7a540f963b5268452a4c95ac74793badc&cachebust=655998. Domains, protocols and ports must match.