zoukankan      html  css  js  c++  java
  • python+selenium自动化可视区域大小获取

    ##  js获取窗口大小    
        #获取网页可见区域大小
        client_width=self.driver.execute_script("return document.body.clientWidth")
        client_height = self.driver.execute_script("return document.body.clientHeight")
        print(client_height,client_width)
        #根据offset获取可见区域大小
        client_width = self.driver.execute_script("return document.body.offsetWidth")
        client_height = self.driver.execute_script("return document.body.offsetHeight")
        print(client_height,client_width)
        # 根据正文全文宽高
        client_width = self.driver.execute_script("return document.body.scrollWidth")
        client_height = self.driver.execute_script("return document.body.scrollHeight")
        print(client_height, client_width)
        # 网页被卷去的宽高
        client_width = self.driver.execute_script("return document.body.scrollLeft")
        client_height = self.driver.execute_script("return document.body.scrollTop")
        print(client_height, client_width)
        # 根据正文部分上左
        client_width = self.driver.execute_script("return window.screenLeft")
        client_height = self.driver.execute_script("return window.screenTop")
        print(client_height, client_width)
        # 根据屏幕分辨率高宽
        client_width = self.driver.execute_script("return window.screen.width")
        client_height = self.driver.execute_script("return window.screen.height")
        print(client_height, client_width)
        # 屏幕可用工作区域高宽
        client_width = self.driver.execute_script("return window.screen.availWidth")
        client_height = self.driver.execute_script("return window.screen.availHeight")
        print(client_height, client_width)

    selenium webdriver获取窗口大小

    driver.get_window_size()
    #返回高宽值,可以根据json取值

    ————————————————
    版权声明:本文为CSDN博主「hthby」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/hthby/article/details/103768663

  • 相关阅读:
    git 之gitignore 添加项之后生效的问题
    使用 padding-bottom 设置高度基于宽度的自适应
    ES5中新增的Array方法详细说明
    zepto.js 自定义打包集成其他模块构建流程
    移动端如何让页面强制横屏
    快来看看抓包工具有哪些?
    实践出真知,小程序wepy,uni-app框架开发使用!
    开发过程遇到的css样式问题记录
    带坑使用微信小程序框架WePY组件化开发项目,附带第三方插件使用坑
    微信 + weui 框架记录
  • 原文地址:https://www.cnblogs.com/Im-Victor/p/14790888.html
Copyright © 2011-2022 走看看