测试16210121003_朱冬梅_基于Selenium Python的自动化测试框架的设计与实现

朱骏身价  时间:2021-01-26  阅读:()

本科毕业设计论文

基于Selenium+Python的自动化测试框架的设计与实现Design and Implementation ofAutomatic Testing

Framework Based on Selenium and Python

院 系 计算机学院软件工程系

专 业 软件工程

班 级 16软件10班

学 号 16210121003

学生姓名 朱冬梅

指导教师 姚庚梅

提交日期 2020年 3月 30日

毕业设计论文原创性声明

本人郑重声明所呈交的毕业设计论文是本人在指导老师的指导下独立进行的设计研究工作及取得的成果论文中引用他人的文献、数据、 图件、资料均已明确标注出论文中的结论和结果为本人独立完成不包含他人已经发表或撰写的作品及成果。对本文的研究作出贡献的个人和集体均已在论文中作了明确的说明。本人完全意识到本声明的法律结果由本人承担。

毕业论文作者签字 签字日期 年 月 日

成绩评定

注毕业设计论文成绩按百分制评定。答辩成绩不及格的评分低于60分的则该毕业设计论文总评成绩为答辩成绩。

中文摘要

随着互联网行业的快速发展敏捷开发快速迭代的性质。传统软件测试的技术和方式并不完全适用于如今的Web系统的测试对于企业引进自动化测试是非常必要的。 目前市场上已经有许多自动化测试工具和框架。如何构建一套适合自我测试的工具或框架满足实际需求的自动化测试框架是每个研究自动化测试或自动化测试的工作者需要考虑和解决的问题。

本文主要是利用软件测试知识、 自动化测试相关教程和自动化测试框架理论在结合对当前市场上流行的自动化测试工具的分析结果使用高效、简洁、灵活的Python语言去实现一款基于S elenium+Python的自动化测试框架该框架的测试对象主要是功能测试。在使用该测试框架过程中需要提高测试脚本的维护性、复用性和扩展性有利于实现减少测试成本的消耗、提高测试执行的效率和保证软件产品的质量。关键词 自动化测试 测试框架 S elenium框架 Pytho n脚本

Abstract

With With the agile development of the Internet industry.Nowadays,traditional software testing techniques and methods are not fully applicableto Web system testing, so it is very necessary for enterprises to introduceautomated testing.At present, there are a lot of automated testing tools andshell frame in the market.How to build a set of self-test means or shell frameto meet the physical demands of automated testing framework is a problemthat every researcher of automated testing or test automation needs toconsider and solve.

This paper mainly uses the knowledge of software testing, related courses of automatic testing and the theory of automatic testing framework.Combining with the analysis results of the popular automatic testing tools in the current market, it uses the effic ient,concise and flexib le Python language to realize an automatic testing framework based on selenium+python.The testingobject of this framework is mainly function testing.

In us ing the test framework at this process,we need to improve themaintainability, reusability and augmentability of test scripts,which isinstrumental in reducing the consumption of test costs, improving theefficiency of test execution and ensuring the quality of software products.Key words Automatic Test Framework Selenium Framework

Python Script

目 录

第一章 绪论...........................................................................................1

1.1 研究背景及意义............................................................................1

1.2 国内外研究现状............................................................................1

1.3 研究目标与内容............................................................................2

1.4 本文结构.......................................................................................3

1.5 本章小结.......................................................................................3

第二章 自动化测试技术研究.................................................................4

2.1 软件自动化测试概念研究.............................................................4

2.1.1 自动化测试定义. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

2.1.2 自动化测试过程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

2.1.3 自动化测试框架分类. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6

2.2 软件自动化测试框架研究.............................................................7

2.2.1 主流自动化测试框架研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

2.2.2 自动化测试框架设计原则研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

2.3 软件自动化测试工具研究.............................................................8

2.3.1 自动化测试工具分类研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

2.3.2 Selenium工具研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9

2.3.3 Selenium WebDriver工具研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9

2.4 Python语言特点介绍..................................................................10

2.5 本章小结.....................................................................................10

第三章 自动化测试框架需求分析.......................................................11

3.1 测试框架功能需求分析...............................................................11

3.1.1 测试用例管理模块测试需求分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

3.1.2 测试业务模块需求分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

3.1.3 数据模块需求分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

3.1.4 日志模块需求分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

3.1.5 测试报告模块需求分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

3.2 测试框架非功能需求分析...........................................................12

3.3 本章小结.....................................................................................13

第四章 自动化测试框架设计...............................................................14

4.1 测试框架的整体架构...................................................................14

4.2 测试业务模块设计......................................................................14

4.2.1 公共类封装. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14

4.2.2 各个页面类封装. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

4.2.3 用例管理模块设计. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

4.3 数据模块设计..............................................................................16

4.4 日志模块设计..............................................................................16

4.4.1 截图. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

4.4.2 自定义日志服务和日志输出. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

4.5 测试报告模块设计......................................................................17

4.5.1 生成测试报告. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17

4.5.2 发送测试报告. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17

4.6 本章小结.....................................................................................17

第五章 自动化测试框架实现...............................................................18

5.1 开发工具.....................................................................................18

5.2 测试框架方案实现......................................................................18

5.3 测试业务模块实现......................................................................19

5.3.1 公共类封装. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19

5.3.2 页面类封装. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

5.3.3 测试用例管理模块实现. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24

5.4 数据模块实现..............................................................................25

5.5 日志模块实现..............................................................................26

5.5.1 截图. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26

5.5.2 自定义日志服务. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26

5.6 测试报告模块实现......................................................................28

5.7 本章小结.....................................................................................28

第六章 应用实践..................................................................................29

6.1 搭建测试环境..............................................................................29

6.2 测试执行.....................................................................................29

6.3 测试报告.....................................................................................30

6.4 本章小结.....................................................................................31

第七章 总结与展望..............................................................................32

7.1总结...............................................................................................32

7.2后续研究展望.................................................................................32

7.3本章小结.......................................................................................32

参考文献...........................................................................................33

致谢........................................................................................................34

图表目录

图2-1 自动化测试基本流程.................................................................5

表2-1 用于黑盒测试的自动化工具......................................................8

表2-2 用于白盒测试的自动化工具......................................................8

表2-3 用于管理测试过程的管理工具..................................................8

图2-2 Selenium - RC的原理..............................................................9

图2-3 Selenium工作基本原理..........................................................10

图3-1 测试框架功能需求分析...........................................................11

图4-1 测试框架的整体结构...............................................................14

图4-2 公共类封装..............................................................................15

图4-3 Testcase结构.........................................................................16

表5-1 开发环境及工具......................................................................18

图5-1 测试框架结构..........................................................................19

图5-2 页面基本操作封装...................................................................20

图5-3 页面元素定位及基本操作封装................................................21

表5-2 八大元素定位..........................................................................21

图5-4 页面基本操作和信息获取封装................................................22

图5-5 浏览器封装..............................................................................22

图5-6 页面类封装..............................................................................24

图5-7 测试用例脚本结构...................................................................24

图5-8 登录页面的测试用例脚本具体实现........................................25

图5-9 登录页面的测试用例输入数据................................................25

图5-10 截图功能封装........................................................................26

图5-11 日志类封装............................................................................27

图5-12 调用第三方库生成测试报告..................................................28

图6-1 正确用例验证登录...................................................................29

VPS云服务器GT线路,KVM虚vps消息CloudCone美国洛杉矶便宜年付VPS云服务器补货14美元/年

近日CloudCone发布了最新的补货消息,针对此前新年闪购年付便宜VPS云服务器计划方案进行了少量补货,KVM虚拟架构,美国洛杉矶CN2 GT线路,1Gbps带宽,最低3TB流量,仅需14美元/年,有需要国外便宜美国洛杉矶VPS云服务器的朋友可以尝试一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2017年的美国服务器...

NameCheap优惠活动 新注册域名38元

今天上午有网友在群里聊到是不是有新注册域名的海外域名商家的优惠活动。如果我们并非一定要在国外注册域名的话,最近年中促销期间,国内的服务商优惠力度还是比较大的,以前我们可能较多选择海外域名商家注册域名在于海外商家便宜,如今这几年国内的商家价格也不贵的。比如在前一段时间有分享到几个商家的年中活动:1、DNSPOD域名欢购活动 - 提供域名抢购活动、DNS解析折扣、SSL证书活动2、难得再次关注新网商家...

如何低价香港服务器购买?有没有便宜的香港服务器推荐?

如何低价香港服务器购买?想要做一个个人博客,想用香港服务器,避免繁琐备案,性能不需要多高,只是记录一些日常而已,也没啥视频之类的东西,想问问各位大佬有没有低价的香港服务器推荐?香港距大陆近,相比美国服务器最大的优势在于延迟低,ping值低,但是带宽紧张,普遍都是1M,一般戏称其为“毛细血管”。同时价格普遍高,优质稳定的一般价格不菲。大厂云梯队阿里云、腾讯云两家都有香港服务器,要注意的是尽量不要选择...

朱骏身价为你推荐
郑州软银筑巢360郑州哪家公司做的好,服务也比较好?涡轮增压和自然吸气哪个好发动机涡轮增压好还是自然吸气好宝来和朗逸哪个好大众朗逸好还是宝来好三国游戏哪个好玩三国游戏哪个最好玩核芯显卡与独立显卡哪个好核芯显卡和独立显卡有什么区别?最好的是哪个?手机管家哪个好手机管家 用什么最好?看书软件哪个好手机读书软件哪个好用?看书软件哪个好小说阅读软件哪个好网页qq空间登录为什么我用网页登录QQ空间时,没有登录界面,直接进去一个QQ空间,请问是怎么回事?dns服务器什么意思DNS服务器是什么意思啊?是指路由器吗?
过期域名 域名查询工具 阿里云os 服务器怎么绑定域名 河南服务器 双线主机 亚马逊香港官网 国外在线代理服务器 中国linux 日本代理ip 双线空间 阿里云邮箱登陆地址 中国电信宽带测速 mteam 免费获得q币 webmin winserver2008下载 建站行业 连连支付 德国代理 更多