Selenium2学习-023-WebUI自动化实战实例-021-获取浏览器显示区域大小,通过 WebDriver 截图功能
2015-08-01 14:33
766 查看
之前的博文 020-JavaScript 在 Selenium 自动化中的应用实例之二(获取浏览器显示区域大小) 简述了通过 JavaScript 获取浏览器显示区域大小,此文将简述另一种获取浏览器显示区域大小的方法,即通过 WebDriver 的截图功能,获取显示区域的截图,通过截图的大小获取浏览器显示区域的大小。
直接上码了,敬请小主们参阅,若有不足之处,敬请大神指正,不胜感激!
至此,WebUI 自动化功能测试脚本第 020-JavaScript 在 Selenium 自动化中的应用实例之二(获取浏览器显示区域大小) 顺利完结,希望此文能够给初学 Selenium 的您一份参考。
最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^
直接上码了,敬请小主们参阅,若有不足之处,敬请大神指正,不胜感激!
/** * Get width and height about display screen area by TakesScreenshot image size * * @author Aaron.ffp * @version V1.0.0: autoSeleniumDemo main.aaron.sele.core SeleniumCore.java getBrowserDisplayAreaSize, 2015-7-28 02:15:01 Exp $ * * @return int[width,height] */ public int[] getBrowserDisplayAreaSize(){ int[] wh = new int[2]; try { // Get byte data of full screen capture byte[] byte_screen_capture = ((TakesScreenshot) this.webdriver).getScreenshotAs(OutputType.BYTES); // create full screen cpature BufferedImage img_screen_catpture = ImageIO.read(new ByteArrayInputStream(byte_screen_capture)); wh[0] = img_screen_catpture.getWidth(); wh[1] = img_screen_catpture.getHeight(); img_screen_catpture = null; byte_screen_capture = null; } catch (Exception e) { e.printStackTrace(); } return wh; }
至此,WebUI 自动化功能测试脚本第 020-JavaScript 在 Selenium 自动化中的应用实例之二(获取浏览器显示区域大小) 顺利完结,希望此文能够给初学 Selenium 的您一份参考。
最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^
相关文章推荐
- Unique Binary Search Tree II
- Postgresql: UUID的使用
- Subsequence
- UIButton常用属性小结(编辑中。。。)
- PAT (Advanced Level) 1099. Build A Binary Search Tree (30) 中序遍历往BST中填数据
- DirectUI界面编程(六)实现右键弹出菜单
- DirectUI界面编程(六)实现右键弹出菜单
- DirectUI界面编程(六)实现右键弹出菜单
- Request processing failed; nested exception is java.lang.NullPointerException
- NSString+NSMutableString+NSArray+NSMutableArray+NSNumber+NSValue用法汇总
- SPOJ QTREE Query on a tree(边权LCT模板)
- NGUI之UI模块基类
- EasyUI学习网站
- druid配置
- 设置uitextview边框
- 错误提示:连接 built-in.o 提示 undefined reference to
- IOS 自定义 tableView cell(UITableViewCell height) 高度
- SolrCloud Wiki翻译(4)Distributed Requests
- UITextfield
- POJ 1679 The Unique MST