我試圖滾動頁面完全使用此代碼:滾動一個Ajax網頁完全使用硒的webdriver
JavascriptExecutor js = (JavascriptExecutor) Browser;
js.executeScript("javascript:window.onload=toBottom();"+
"function toBottom(){" +"window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +"document.body.scrollHeight,document.documentElement.clientHeight));" +"}");
js.executeScript("window.status = 'fail';");
//Attach the Ajax call back method
js.executeScript("$(document).ajaxComplete(function() {" + "status = 'success';});");
js.executeScript("window.status = 'fail';");
//Attach the Ajax call back method
js.executeScript("$(document).ajaxComplete(function() {" +"status = 'success';});");
此代碼工作正常,並滾動頁面的第一次嘗試,但是當頁面滾動下來,新數據出現在頁面上,並且此代碼無法再次滾動。 所以我需要的是有人會幫我滾動頁面直到結束,直到滾動完成。
我爲此使用任何循環嗎?
幫助/建議/反應將不勝感激!
頁面的例子? – stanjer
例如,您可以考慮twitter或linkedin主頁,例如當您向下滾動顯示更多推文時。 –
但該頁面上沒有「結束」 – stanjer