def scroll_until_loaded1(self): check_height = self.driver.execute_script("return document.body.scrollHeight;") js = r‘‘‘ function a(h){ var timer = null; timer = setInterval(function(){ console.log(document.body.scrollHeight) console.log("h1 : " + h) if (h<=document.body.scrollHeight) { h = h + 100; window.scrollTo(0, h); }else{ clearInterval(timer); return true; } },300) } a() ‘‘‘ self.driver.execute_script(js) try: self.wait.until( lambda driver: self.driver.execute_script(js)) except TimeoutException: pass
原文:https://www.cnblogs.com/shijiu520/p/12082078.html