首页 > 编程语言 > 详细

python 执行js 代码 滚动当前页面

时间:2019-12-23 10:13:58      阅读:95      评论:0      收藏:0      [点我收藏+]
    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

 

python 执行js 代码 滚动当前页面

原文:https://www.cnblogs.com/shijiu520/p/12082078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!