当前位置:网站首页>Selenium测试页面内容下载功能
Selenium测试页面内容下载功能
2022-07-20 18:43:00 【zljun8210】
因项目需要,需测试页面支持的导出到Excel功能,现记录如下。
导出功能在不同页面有不同实现方式,现将两种页面实现及测试记录下来。
1、 第1种,通过统计tr元素来确定要导出的数据量。
其页面文件如下:
获取内容的测试代码:
# 获取有多少条数据
assetgrid = self.driver.find_element_by_xpath('//*[@id="tab_grid"]/div/div[1]/div/table/tbody')
assets = assetgrid.find_elements_by_xpath('tr')
assetcounts = len(assets) - 1
log.info('页面显示有 %d 条数据' % assetcounts)
2、 第2种,通过元素高度来计算(因为数据超过1页,而tr元素方式只能统计当前1页的数据量)
页面文件如下:
测试代码如下:
grids = self.driver.find_element_by_xpath('//*[@id="machinelist"]/div/div[1]/div')
hei = grids.size["height"]
counts = int(hei) / 27
log.info('当前有 %d 条数据' % counts)
边栏推荐
- 西农大 C plus
- 【开发教程6】疯壳·ARM功能手机-中断实验教程
- Memory allocation method
- 代码评审中用好7招,成功建立起你的反对同盟
- Spark Learning (1) -spark Foundation
- 7.7 B tree and b+ tree
- How do PR video editors choose notebooks? ASUS lingyao pro16 2022 brings you to play with content creation
- Operation and maintenance experience sharing of stolen mailbox disposal in Colleges and Universities - Tsinghua University
- 2022数学建模“五一杯”B题 题解+论文
- 从头开始实现 Promise
猜你喜欢
字节开出三倍工资:挖我同事做芯片
12.2 package and import package
前中电技术总监精讲高频面试题:谈谈你对负载均衡的理解
阿里云联合平行云推出云XR平台,支持沉浸式体验应用快速落地
【语音识别】隐马尔可夫模型HMM
Use the add () method in calendar to add and subtract time, obtain the time range, and read the dynamic data dictionary.
从一线开发到技术总监,你就差一个赶鸭子上架
Dart:补充
C language - Sanzi game
为啥有些经理,总是强行刷存在感?(你遇到过吗?)
随机推荐
Insights on the growth process of coinbase 2021-04-15
每日刷题记录 (二十九)
Professional creation ASUS proart Chuang 16 2022 pre-sale, efficient creation of a new flagship
The source code of the live broadcast system is automatically filled in when logging in
CAD网页中实现嵌套打印
短视频带货源码, 文本上下滚动和图片闪烁
Kubernetes v1.24 is deployed based on containerd
如何优雅的实现MySQL 数据库定时备份(荣耀典藏版)
UGUI 基础控件 第二部分
【身份证号校验】
话实践,行实干,成实事:“巡礼”数字化的中国大地
11.3 construction method
12 static and static initialization parameter value transfer
电商项目中订单系统到底该怎么设计才好?(至尊典藏版)
Foreach loop statement in TP5 controller
16 package
经典重温:理解神经网络的“知识一致性”(ICLR 2020)
为啥有些经理,总是强行刷存在感?(你遇到过吗?)
Use cpolar to build a business website (2)
14 object class = = and equals