- 博客(15)
- 收藏
- 关注
原创 一个简单的web自动化测试用例(webdriver 与 unittest 结合)
#coding=utf-8from selenium import webdriverimport unittestimport timeimport sysreload(sys)sys.setdefaultencoding('utf8')class MyTest(unittest.TestCase): def setUp(self): self.dri...
2018-08-14 17:40:43
2027
原创 python 单元测试框架 unittest
单元测试框架的用途:提供用例组织与执行、提供丰富断言方法、提供丰富的日志unittest的4个重要概念:1. TestCase :一个TestCase的实例就是一个测试用例,一个完整的测试流程,包括测试前准备环境的搭建(setUp)、实现测试过程的代码(以"test"开头的方法)、测试后环境的还原(tearDown)2. TestSuite: 一个功能的验证往往需要多个测试用例,可以把...
2018-08-14 17:28:19
260
原创 (selenium系列之八)切换
web应用中经常有iframe表单嵌套、跳转不同窗口、弹出警告框、确认框等的情况,就需要切换进去才能操作。表单切换:driver.switch_to.frame('child_frame')表单切回:driver.switch_to.parent_frame()多窗口切换:driver.switch_to.window("new_window_handle")切换到警告框:driv...
2018-08-14 11:00:08
188
原创 (selenium系列之七)元素等待
当浏览器加载页面时,页面上的元素可能不能同时被加载完成,如果在加载某个元素时延迟可能造成ElementNotVisibleException.针对这种情况可以设置元素等待改善脚本执行的稳定性。webdriver 提供了两种类型的等待:显示等待 和 隐式等待time模块也提供等待:time.sleep(10) 强制等待10秒显示等待:显示等待使Webdriver等待某个条件成立时继续执行...
2018-08-14 10:48:06
231
原创 (selenium系列之六)selenium 获取验证信息
常用的验证信息有 title、URL、text,获取方式如下:title = driver.titlenow_url = driver.current_urluser = driver.find_element_by_id("user").text 验证:assert '百度' in titleassert now_url == "http://www.baidu.co...
2018-08-13 18:49:42
484
原创 (selenium系列之五)键盘事件
模拟键盘事件可以使用Keys类提供的键盘方法,具体如下:#coding=utf-8from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdriver = webdriver.Chrome()driver.get("http://www.baidu.com")driver.fin...
2018-08-13 18:22:27
378
原创 (selenium系列之四)webdriver 操作鼠标
ActionChains 类提供了鼠标操作常用的方法:perform() 执行所有ActionChains中存储的行为context_click() 右击double_click() 双击drag_and_drop() 拖动move_to_element() 鼠标悬停#coding=utf-8from selenium import webdriverfrom...
2018-08-13 18:21:26
201
原创 (selenium系列之三)webdriver 操作元素
清除文本:ele.clear()模拟按键输入:ele.send_keys(*value)点击元素:ele.click()提交:ele.submit()上传文件:ele.send_keys("D:/abc.txt") 只针对这种情况:标签是<input type='file' name='file'>下载文件:#coding=utf-8from selen...
2018-08-13 17:48:26
179
原创 (selenium系列之二)webdriver 操作浏览器
d控制浏览器窗口大小:driver.set_window_size(480,800)控制浏览器前进、后退:driver.forward()、driver.back()刷新浏览器:driver.refresh()操作cookie:all_cookies = driver.get_cookies() 获取所有cookie信息 specific_cookie = drive...
2018-08-13 16:15:31
254
原创 (selenium系列之一)selenium元素定位
下周就要入职新公司了,提前把基础知识再巩固一下。selenium 有两个不同的类都提供了元素定位的方法:webdriver , By1. 调用WebDriver类里的方法参考源码: %pythonENV%\Lib\site-packages\selenium\webdriver\remote\webdriver.py使用方法为:#coding=utf-8from selen...
2018-08-13 15:38:23
221
转载 转载的sql语句
1 查询每门课程成绩都大于80分学生的学号数据库 表 studentname score courseA 85 语文A 75 数学A 82 英语B 75 语文B 89 数学B 79 英语天使美眉90 语文天使美眉100 数学天使美眉100 英语请找出每门课程都超过80分的那个人名字的SQL语句SQL1:select name from test....
2018-07-12 18:32:33
196
转载 python的数据类型和常用方法
python有5种标准的数据类型:数字(Number)、字符串(String)、列表(List)、元组(Tuple)、字典(Dictionary) 其他常用的数据类型有 集合(set)、文件(file)下面总结一下每种数据类型常用的方法和关键字:1. 数字(Number): 包括 int(有符号整型)、long(长整型,也可代表八进制和十六进制)、float(浮点型)、complex(复数)赋值:...
2018-07-11 13:34:35
301
原创 adb shell --help
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER] pm list permission-groups pm list permissions [-g] [-f] [-d] [-u] [GROUP] pm list instrumentation...
2018-07-10 18:26:11
614
转载 adb 命令
1)查看当前所有连接的设备的命令,断开当前连接的设备的命令adb devices , adb disconnect <device-ip-address>2) 向指定设备发送指令adb -s <serial-number> <shell>adb -s SH0A6PL99999 pull data/data/com.android.tencent/da...
2018-07-10 18:12:27
292
原创 RF+Selenium2Library元素定位不到的问题
在基于RobotFramework框架使用Selenium2Library库对web系统做UI自动化时经常会遇到元素定位不到的问题,就我目前所遇到的情况,除元素本身定位有误外,大致有5类问题导致元素定位不到,即休眠时间较短、未进入frame、未进行窗口跳转、元素被隐藏、元素为只读。其中,元素被隐藏的解决方法我有参考网上的资料,参考链接见正文。 1. 等待时间太短,页面元素还没加载出来,或者...
2017-09-18 10:47:43
5257
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人