Edit :这是windows的行为,linux就失败了。
首先,如果您使用 casper 成功导航 gmail(没有随机等待时间 - 从 20 秒到 5 分钟 -),请告诉我。
我想在我们的网站上注册,然后使用 Gmail 自动验证我的注册(整个注册步骤)。以前有人这样做过吗?
我注册没有问题,并且可以登录我的邮箱(Gmail),但是在导航和验证 Gmail 中的注册时遇到一些麻烦后,我观察到 phantomJS 和 slimerJS 之间的不同行为。
在幻影中,它可以工作(无需特殊命令),但可能需要 5 分钟才能进入下一步(waitForSelector)。而使用 slimerjs,它只会停留在邮箱页面上。
EDIT : 一件奇怪的事情:如果我手动单击(更细)打开弹出窗口的链接,它就会停止被阻止并且我的导航继续,就像它无法检测到步骤本身的结束并且无法在之后执行 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 ,但不起作用)。
这里是 phantom 和 slimer 之间的区别(doc):http://docs.slimerjs.org/0.8/differences-with-phantomjs.html http://docs.slimerjs.org/0.8/differences-with-phantomjs.html(我认为在这个问题上没用)