互联网公司网站建设ppt模板下载,更换网站后台管理系统,聊城做网站的公司新闻,wordpress默认主题下载一#xff0c;线性测试
1.概念#xff1a;
通过录制或编写对应应用程序的操作步骤产生的线性脚本。单纯的来模拟用户完整的操作场景。
#xff08;操作#xff0c;重复操作#xff0c;数据#xff09;都混合在一起。
2.优点#xff1a;
每个脚本相对独立#xff0…一线性测试
1.概念
通过录制或编写对应应用程序的操作步骤产生的线性脚本。单纯的来模拟用户完整的操作场景。
操作重复操作数据都混合在一起。
2.优点
每个脚本相对独立且不产生其他依赖和调用。
3.缺点
开发成本高用例之间存在重复的操作。比如重复的用户登录和退出。
维护成本高由于重复的操作当重复的操作发生改变时则需要逐一进行脚本的修改。
4.线性测试实例
用户登录
以下的用户名密码到时候自己去申请就不将笔者的用户密码贴出来了。
# codingutf-8Created on 2016-7-20
author: Jennifer
Project:简单元素操作登录126邮箱元素的clear()send_keys(),click()操作
在定位的时候发现有些元素定位不到最后发现有iframeframe中实际上是嵌入了另一个页面。
如果iframe有name或id的话直接使用switch_to_frame(name值)或switch_to_frame(id值)
这是最理想的方法也是最简单好用的方法。from selenium import webdriver
import timedriverwebdriver.Firefox()
driver.get(rhttp://www.126.com/) #字符串加r防止转义。
time.sleep(3)print 开始登录邮箱try:assert 126 in driver.title #title是变量不能title()
except AssertionError:print error网址输入不正确
else:print 记录日志网址输入正确# driver.switch_to_frame(x-URS-iframe) #跳转到iframe框架driver.switch_to.frame(x-URS-iframe) #同上面语句一样跳转到iframe框架usernamedriver.find_element_by_name(email)username.clear()username.send_keys(Jennifer···)time.sleep(0.1)userpasswddriver.find_element_by_name(password)userpasswd.clear()userpasswd.send_keys(·····)time.sleep(0.1)loginbtdriver.find_element_by_id(dologin)loginbt.click()time.sleep(3)try:assert 网易邮箱 in driver.titleexcept AssertionError:print 邮箱登录失败else:print 邮箱登录成功finally:#操作收信写信等操作暂不写例子了driver.quit()print 测试结束
二模块化驱动测试
1.概念
将重复的操作独立成功共模块当用例执行过程中需要用到这一模块操作时则被调用。
操作重复操作数据混合在一起。
2.优点
由于最大限度消除了重复从而提高了开发效率和提高测试用例的可维护性。
3.缺点
虽然模块化的步骤相同但是测试数据不同。比如说重复的登录模块如果登录用户不同依旧要重复编写登录脚本。
4.实例
公共模块对登陆和退出进行模块化封装
以下的用户名密码到时候自己去申请就不将笔者的用户密码贴出来了。
# codingutf-8Created on 2016-7-27
author: Jennifer
Project:模块化驱动测试实例将重复的登录脚本放在单独的脚本中供其他用例调用import time
class Login():def user_login(self,driver):usernamedriver.find_element_by_name(email)username.clear()username.send_keys(username)time.sleep(0.1)userpasswddriver.find_element_by_name(password)userpasswd.clear()userpasswd.send_keys(password)time.sleep(0.1)loginbtdriver.find_element_by_id(dologin)loginbt.click()time.sleep(3)def user_logout(self,driver):driver.find_element_by_link_text(u退出).click()driver.quit()
写信用例以下代码用了各种定位方法值得学习后续再重新对这部分进行总结
直接调用模块的登录和退出方法。
收信用例
直接调用模块的登录和退出方法。
# codingutf-8Created on 2016-7-27
author: Jennifer
Project:接收邮件from selenium import webdriver
import timefrom test_5_2_public import Login
driverwebdriver.Firefox()
driver.implicitly_wait(30)
driver.get(rhttp://www.126.com/) #字符串加r防止转义。
time.sleep(3)
driver.switch_to.frame(x-URS-iframe)
#调用登录模块
Login().user_login(driver)
time.sleep(10)
#接收邮件
#点击收信
#以下定位是查找span标签有个文本text包含contains收 信 的元素该定位方法重要
driver.find_element_by_xpath(//span[contains(text(),收 信)]).click()#校验是否进入收件箱没报错即进入
try:#点击其中一封邮件driver.find_element_by_xpath(//div[signletter]).click()
except Exception as e:print e
else:print 成功收信#调用退出模块
Login().user_logout(driver)
三数据驱动测试
1.概念
它将测试中的测试数据和操作分离数据存放在另外一个文件中单独维护。
通过数据的改变从而驱动自动化测试的执行最终引起测试结果的改变。
操作重复操作数据分开。
2.优点
通过这种方式将数据和重复操作分开可以快速增加相似测试完成不同数据情况下的测试。
3.缺点
暂无
4.实例
从excel表格读取用户名密码登录邮箱。
以下的用户名密码到时候自己去申请就不将笔者的用户密码贴出来了。 # codingutf-8Created on 2016-7-28
author: Jennifer
Project:数据驱动测试数据保存在excel中需要导入xlrd模块from selenium import webdriver
import time
import xlrd#将用户密码表格转换为用户密码列表
def exceltolist(excelfile,colnameindex0,by_index0):excelfilexlrd.open_workbook(excelfile) #打开excel表格
# table excelfile.sheets()[by_index] #默认获取sheet0页table excelfile.sheet_by_index(by_index)#默认获取sheet0页nrowstable.nrows #获取excel的sheet0页的行数colnamestable.row_values(colnameindex) #默认获取第0行的列表数据name和password两个值list [] #建一个空列表用来存放用户密码字典for rownum in range(1,nrows): #初始行为0从第1行开始row table.row_values(rownum) #获取某一行的列表数据if row:app {} #建立一个空字典存放某一组用户密码数据for i in range(len(colnames)): #目前是2app[colnames[i]] row[i] #字典新增数据循环两次字典新增两对key-valuelist.append(app) #将新增的字典数据添加到列表数据中 return listdef Login():filerD:\pythontest\rightpassword\userpassword.xlsuserlistexceltolist(file)for i in range(len(userlist)):driverwebdriver.Firefox()driver.get(rhttp://www.126.com/) #字符串加r防止转义。time.sleep(3)driver.switch_to.frame(x-URS-iframe) #同上面语句一样跳转到iframe框架usernamedriver.find_element_by_name(email)username.clear()username.send_keys(userlist[i][name])time.sleep(0.1)userpasswddriver.find_element_by_name(password)userpasswd.clear()userpasswd.send_keys(userlist[i][password])time.sleep(0.1)loginbtdriver.find_element_by_id(dologin)loginbt.click()time.sleep(3)try:assert 网易邮箱 in driver.titleexcept AssertionError:print 用户%s邮箱登录失败%(userlist[i][name])else:print 用户%s邮箱登录成功%(userlist[i][name])finally:driver.quit()if __name____main__:Login()四关键字驱动测试
1.概念
通过关键字的改变从而驱动自动化测试的执行最终引起测试结果的改变。关键字驱动工具有RobotFrameworkRIDE。
2.优点
视频里有讲解
自动化测试【Requests接口自动化测试实战】 文章转载自: http://www.morning.pbygt.cn.gov.cn.pbygt.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.czwed.com.gov.cn.czwed.com http://www.morning.kzpy.cn.gov.cn.kzpy.cn http://www.morning.hfbtt.cn.gov.cn.hfbtt.cn http://www.morning.gpryk.cn.gov.cn.gpryk.cn http://www.morning.dfbeer.com.gov.cn.dfbeer.com http://www.morning.sfcfy.cn.gov.cn.sfcfy.cn http://www.morning.nwnbq.cn.gov.cn.nwnbq.cn http://www.morning.nhdmh.cn.gov.cn.nhdmh.cn http://www.morning.xsgxp.cn.gov.cn.xsgxp.cn http://www.morning.mmxnb.cn.gov.cn.mmxnb.cn http://www.morning.gkxyy.cn.gov.cn.gkxyy.cn http://www.morning.rkjz.cn.gov.cn.rkjz.cn http://www.morning.mbdbe.cn.gov.cn.mbdbe.cn http://www.morning.rghkg.cn.gov.cn.rghkg.cn http://www.morning.tzzkm.cn.gov.cn.tzzkm.cn http://www.morning.dtnzk.cn.gov.cn.dtnzk.cn http://www.morning.xznrk.cn.gov.cn.xznrk.cn http://www.morning.kndt.cn.gov.cn.kndt.cn http://www.morning.tslwz.cn.gov.cn.tslwz.cn http://www.morning.gqfks.cn.gov.cn.gqfks.cn http://www.morning.xhjjs.cn.gov.cn.xhjjs.cn http://www.morning.lmfxq.cn.gov.cn.lmfxq.cn http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn http://www.morning.nxfwf.cn.gov.cn.nxfwf.cn http://www.morning.xgchm.cn.gov.cn.xgchm.cn http://www.morning.rrdch.cn.gov.cn.rrdch.cn http://www.morning.gassnw.com.gov.cn.gassnw.com http://www.morning.lsjtq.cn.gov.cn.lsjtq.cn http://www.morning.ncqzb.cn.gov.cn.ncqzb.cn http://www.morning.schwr.cn.gov.cn.schwr.cn http://www.morning.fpngg.cn.gov.cn.fpngg.cn http://www.morning.ctfh.cn.gov.cn.ctfh.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.dwztj.cn.gov.cn.dwztj.cn http://www.morning.nicetj.com.gov.cn.nicetj.com http://www.morning.jkzq.cn.gov.cn.jkzq.cn http://www.morning.xsbhg.cn.gov.cn.xsbhg.cn http://www.morning.swimstaracademy.cn.gov.cn.swimstaracademy.cn http://www.morning.dbqg.cn.gov.cn.dbqg.cn http://www.morning.pthmn.cn.gov.cn.pthmn.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.lwrcg.cn.gov.cn.lwrcg.cn http://www.morning.rgrys.cn.gov.cn.rgrys.cn http://www.morning.ghrlx.cn.gov.cn.ghrlx.cn http://www.morning.tlnbg.cn.gov.cn.tlnbg.cn http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn http://www.morning.lokext.com.gov.cn.lokext.com http://www.morning.azxey.cn.gov.cn.azxey.cn http://www.morning.zbqry.cn.gov.cn.zbqry.cn http://www.morning.gcdzp.cn.gov.cn.gcdzp.cn http://www.morning.hbnwr.cn.gov.cn.hbnwr.cn http://www.morning.sknbb.cn.gov.cn.sknbb.cn http://www.morning.gqjzp.cn.gov.cn.gqjzp.cn http://www.morning.zfrs.cn.gov.cn.zfrs.cn http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn http://www.morning.jwlmm.cn.gov.cn.jwlmm.cn http://www.morning.nzms.cn.gov.cn.nzms.cn http://www.morning.ynstj.cn.gov.cn.ynstj.cn http://www.morning.qnhpq.cn.gov.cn.qnhpq.cn http://www.morning.mtyhk.cn.gov.cn.mtyhk.cn http://www.morning.zyffq.cn.gov.cn.zyffq.cn http://www.morning.paxkhqq.cn.gov.cn.paxkhqq.cn http://www.morning.ddzqx.cn.gov.cn.ddzqx.cn http://www.morning.lzqtn.cn.gov.cn.lzqtn.cn http://www.morning.zrpbf.cn.gov.cn.zrpbf.cn http://www.morning.pghgq.cn.gov.cn.pghgq.cn http://www.morning.kfjnx.cn.gov.cn.kfjnx.cn http://www.morning.wktbz.cn.gov.cn.wktbz.cn http://www.morning.rfkyb.cn.gov.cn.rfkyb.cn http://www.morning.dansj.com.gov.cn.dansj.com http://www.morning.fmqng.cn.gov.cn.fmqng.cn http://www.morning.rwmqp.cn.gov.cn.rwmqp.cn http://www.morning.tgmfg.cn.gov.cn.tgmfg.cn http://www.morning.xhxsr.cn.gov.cn.xhxsr.cn http://www.morning.ghqyr.cn.gov.cn.ghqyr.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.tpwrm.cn.gov.cn.tpwrm.cn http://www.morning.nflpk.cn.gov.cn.nflpk.cn