我想使用http://docs.casperjs.org/en/latest/modules/casper.html#waitforurl中的waitForUrl()函數。在發送登錄表單之後,casperjs應該等待下一頁被加載。在下面的代碼中,您會看到「第二個變體」,這是我嘗試對此進行編碼的方式,您也會看到發生的錯誤消息。 「第一個變體」正在工作,因此dashboard.png被捕獲。Casperjs和waitForUrl()等待下一頁
有人可以解釋「第二個變體」有什麼問題嗎?
// ...
// Type and send login Form
casper.then(function() {
this.evaluate(function(){
$("username").value="admin";
$("password").value="pass#";
$("login").click();
});
});
// First variant (works) -----------------
// casper.then(function() {
// this.clickLabel('Dashboard', 'a');
// });
// Second variant (works not, error) -----------------
// casper.waitForUrl(/\/admin\/index\.php/,function() {
// this.clickLabel('Dashboard', 'a');
//});
// -> [error] [phantom] Wait timeout of 5000ms expired, exiting.
// -> Wait timeout of 5000ms expired, exiting.
casper.then(function(){
this.capture('./dashboard.png');
});
http://docs.casperjs.org/en/latest/modules/casper.html#waitforurl –
@Igor我已經在我的問題中發佈了該鏈接!我的代碼有什麼問題?看不到我的代碼和文檔之間的任何區別。 –