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

  • 相关阅读:
    Moo.fx 超级轻量级的 javascript 特效库
    Oracle 异常错误处理
    变被动为主动
    数据结构定义
    Redis 一个keyvalue存储系统 简介
    使用Container.ItemIndex获取Repeater、Gridview行的序号的简单方法
    ORACLE SQL:经典查询练手第一篇
    MongoDB 一个基于分布式文件存储的数据库
    dojo Quick Start/dojo入门手册面向对象,定义Class
    面向过程分析与面向对象分析之间的区别
  • 原文地址:https://www.cnblogs.com/Im-Victor/p/14790888.html
Copyright © 2011-2022 走看看