编辑:这是 Windows 的行为,在 linux 中它只是失败了。
首先,如果您使用 casper 成功在 gmail 上导航(没有随机等待时间 - 从 20 秒到 5 分钟),请告诉我。
我想在我们的网站上注册,然后通过 Gmail 自动验证我的注册(整个注册步骤)。以前有人这样做过吗?
我注册没有问题,我可以登录我的邮箱(Gmail),但是在我在 Gmail 中导航和验证我的注册时遇到了一些麻烦,我观察到 phantomJS 和 slimerJS 之间的不同行为。
在幻像中它会工作(没有特殊命令),但可能需要 5 分钟才能通过下一步(waitForSelector)。使用 slimerjs,它只会停留在邮箱页面上。
编辑:奇怪的事情:如果我在打开弹出窗口的链接上手动单击(更苗条),它将停止被阻止并且我的导航继续,就像它无法检测到步骤本身的结束并且无法执行 waitFor提交点击后没有其他交互。是刷新/重新加载问题吗?
试试看自己:
casper.thenOpen('https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/&hl=en', function(){
this.sendKeys("input#Email","your mail");
this.sendKeys("input#Passwd","your password");
this.click("input#signIn.rc-button-submit");
console.log(this.getCurrentUrl());
this.waitForSelector(".aeF",function(){//fail with linux -> timeout
this.test.pass("ok"); //windows -> stuck in slimer, several times in phantom
this.test.assertExists(".T-I.J-J5-Ji.T-I-KE.L3","Gmail Home ok");
console.log("url "+this.getCurrentUrl());
});
而且我没有收到任何超时错误。在 slimerjs 中,它只是保持页面打开。
如果我执行 waitForPopup 而不是 waitForUrl,则会出现错误(超时 -> 未弹出),那么为什么 waitForUrl/waitForSelector... 会卡住?我也尝试了 --web-security=no,--ignore-ssl-errors=true 命令(未链接,但我也尝试了 --output-encoding=ISO 8859-1 ,但它不起作用)。
这里幻影和苗条(doc)之间的区别:http://docs.slimerjs.org/0.8/differences-with-phantomjs.html( 我 认为在这个问题上没用)