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

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


  • 相关阅读:
    结婚也可以2.0!
    最近读书清单
    Win7旗舰版中的IIS配置asp.net的运行环境
    Google Chrome浏览器
    MySQL到NoSQL:数据的重思和查询方式的转换
    sqlserver游标概念与实例全面解说
    高效管理ASP.NET的JavaScript库
    如何提取网页中的flash
    如何手动启动tomcat
    tomcat单词缩写
  • 原文地址:https://www.cnblogs.com/interdrp/p/15523988.html
Copyright © 2011-2022 走看看