2013-12-14 49 views
2

據我所知open()waitFor()需要以下步驟被包裹在then()我需要在then()中包裝更多的waitFor()步驟嗎?

casper.click(x('//button[text()="Login"]')); 

casper.waitForSelector(x('//span[text()="Navigation"]]')); 

casper.capture('1.png'); 

casper.then(function() { 
    casper.capture('2.png'); // Only this shows the navigation 
}); 

當我有多個waitFor()步驟,我需要把它們連自己還是他們自己的連鎖?

casper.click(x('//button[text()="Login"]')); 
casper.waitForSelector(x('//span[text()="Navigation"]]')); 
casper.waitWhileSelector(x('//span[text()="Loading"]]')); 
casper.then(function() { 
    casper.capture('1.png'); // Under which condition will this be executed? 
}); 

回答

0

casper.wait*的功能是在同樣的方式,casper.then是步驟。所以他們不需要被包裝在then中。如果你這樣做,請記住,wait*的內部步驟將在更高(分層)級別的所有其他步驟後添加到隊列中。

第二個代碼執行與描述相同。 wait*函數會等待。