.....................4
1.4Selenium简介........................................................................................................4
1.5appium简介...........................................................................................................8
第2章测试环境搭建..................................................................................................10
2.1安装Python..........................................................................................................10
2.2安装Selenium......................................................................................................12
2.3第一个Selenium自动化测试脚本.....................................................................12
2.4浏览器驱动..........................................................................................................13
第3章Python基础.....................................................................................................16
3.1Python哲学..........................................................................................................16
3.2输出......................................................................................................................18
3.2.1打印..........................................................................................................18
3.2.2引号与注释..............................................................................................19
3.3分支与循环..........................................................................................................20
3.3.1if语句.......................................................................................................20
3.3.2for语句....................................................................................................21
3.4列表、元组与字典..............................................................................................22
3.4.1列表..........................................................................................................22
3.4.2元组..........................................................................................................23
3.4.3字典..........................................................................................................24
3.5函数、类和方法..................................................................................................25
3.5.1函数..........................................................................................................25
3.5.2类和方法..................................................................................................26
3.6模组......................................................................................................................27
3.6.1调用模块..................................................................................................27
3.6.2自定义模块..............................................................................................30
3.6.3跨目录调用文件......................................................................................31
3.6.4编写自测代码..........................................................................................33
3.7异常......................................................................................................................34
3.7.1认识异常..................................................................................................34
3.7.2更多异常用法..........................................................................................37
3.7.3抛出异常..................................................................................................37
3.8新手常犯的错误..................................................................................................38
第4章WebDriverAPI................................................................................................40
4.1从定位元素开始..................................................................................................40
4.1.1id定位......................................................................................................44
4.1.2name定位................................................................................................44
4.1.3class定位.................................................................................................44
4.1.4tag定位....................................................................................................44
4.1.5link定位...................................................................................................45
4.1.6partiallink定位........................................................................................45
4.1.7XPath定位...............................................................................................46
4.1.8CSS定位..................................................................................................48
4.1.9用By定位元素.......................................................................................51
4.2控制浏览器..........................................................................................................52
4.2.1控制浏览器窗口大小..............................................................................52
4.2.2控制浏览器后退、前进..........................................................................52
4.2.3模拟浏览器刷新......................................................................................53
4.3WebDriver中的常用方法....................................................................................53
4.4鼠标操作..............................................................................................................55
4.5键盘操作..............................................................................................................57
4.6获得验证信息......................................................................................................58
4.7设置元素等待......................................................................................................59
4.7.1显式等待..................................................................................................60
4.7.2隐式等待..................................................................................................62
4.8定位一组元素......................................................................................................63
4.9多表单切换..........................................................................................................64
4.10多窗口切换........................................................................................................65
4.11警告框处理........................................................................................................67
4.12下拉框处理........................................................................................................69
4.13上传文件............................................................................................................70
4.14下载文件............................................................................................................72
4.15操作Cookie........................................................................................................74
4.16调用JavaScript...................................................................................................75
4.17处理HTML5视频播放.....................................................................................77
4.18滑动解锁............................................................................................................79
4.19窗口截图............................................................................................................82
4.20关闭窗口............................................................................................................83
第5章自动化测试模型...............................................................................................84
5.1基本概念..............................................................................................................84
5.2自动化测试模型..................................................................................................85
5.3模块化与参数化..................................................................................................86
5.4读取数据文件......................................................................................................89
5.4.1读取txt文件............................................................................................89
5.4.2读取CSV文件........................................................................................91
5.4.3读取XML文件.......................................................................................92
5.4.4读取JSON文件.......................................................................................94
第6章unittest单元测试框架......................................................................................96
6.1认识unittest..........................................................................................................97
6.1.1认识单元测试..........................................................................................97
6.1.2重要的概念............................................................................................100
6.1.3断言方法................................................................................................103
6.1.4测试用例的组织与discover方法.........................................................104
6.2关于unittest还需要知道的...............................................................................108
6.2.1测试用例的执行顺序............................................................................108
6.2.2执行多级目录的测试用例....................................................................110
6.2.3跳过测试和预期失败............................................................................111
6.2.4Fixtures...................................................................................................113
6.3编写Web自动化测试.......................................................................................114
第7章unittest扩展...................................................................................................118
7.1HTML测试报告................................................................................................118
7.1.1下载与安装............................................................................................118
7.1.2生成HTML测试报告...........................................................................119
7.1.3更易读的测试报告................................................................................121
7.1.4测试报告文件名....................................................................................123
7.2数据驱动应用....................................................................................................124
7.2.1数据驱动................................................................................................125
7.2.2Parameterized.........................................................................................128
7.2.3DDT........................................................................................................130
7.3自动发送邮件功能............................................................................................134
7.3.1Python自带的发送邮件功能................................................................134
7.3.2用yagmail发送邮件.............................................................................136
7.3.3整合自动发送邮件功能........................................................................137
第8章PageObject..................................................................................................140
8.1认识PageObject................................................................................................140
8.2实现PagetObject...............................................................................................141
8.2.1PagetObject简单实例...........................................................................142
8.2.2改进PagetObject封装..........................................................................143
8.3poium测试库.....................................................................................................146
8.3.1基本使用................................................................................................147
8.3.2更多用法................................................................................................148
第9章pytest单元测试框架......................................................................................150
9.1pytest简单例子..................................................................................................150
9.2pytest的基本使用方法......................................................................................152
9.2.1断言........................................................................................................152
9.2.2Fixture....................................................................................................153
9.2.3参数化....................................................................................................157
9.2.4运行测试................................................................................................158
9.2.5生成测试报告........................................................................................160
9.2.6conftest.py..............................................................................................162
9.3pytest扩展..........................................................................................................163
9.3.1pytest-html..............................................................................................163
9.3.2pytest-rerunfailures.................................................................................164
9.3.3pytest-parallel扩展................................................................................165
9.4构建Web自动化测试项目...............................................................................166
9.4.1项目结构介绍........................................................................................166
9.4.2主要代码实现........................................................................................168
9.4.3测试用例的运行与测试报告................................................................173
第10章SeleniumGrid.............................................................................................176
10.1SeleniumGrid介绍.........................................................................................176
10.1.1SeleniumServer环境配置...................................................................176
10.1.2SeleniumGrid工作原理......................................................................178
10.2SeleniumGrid应用..........................................................................................180
10.2.1Remote实例.........................................................................................181
10.2.2Grid执行过程......................................................................................183
10.2.3创建远程节点......................................................................................185
第11章Jenkins持续集成.........................................................................................187
11.1下载Tomcat......................................................................................................188
11.2下载Jenkins.....................................................................................................189
11.3安装配置Jenkins.............................................................................................190
11.4Jenkins的基本使用..........................................................................................192
11.4.1创建一个构建任务..............................................................................192
11.4.2运行Python测试.................................................................................195
11.4.3安装插件..............................................................................................196
11.5Selenium自动化项目配置..............................................................................197
11.5.1配置Git/GitHub...................................................................................197
11.5.2配置项目运行......................................................................................200
11.5.3配置HTML报告.................................................................................201
11.5.4配置构建统计......................................................................................204
11.5.5配置自动发送邮件..............................................................................205
第12章appium的介绍与安装..................................................................................210
12.1appium介绍.....................................................................................................210
12.1.1移动应用类型......................................................................................210
12.1.2appium的架构.....................................................................................211
12.1.3appium的工作过程.............................................................................214
12.2appium环境搭建.............................................................................................215
12.2.1AndroidStudio.....................................................................................216
12.2.2Android模拟器....................................................................................219
12.2.3appiumDesktop....................................................................................222
12.2.4PythonClient........................................................................................223
12.2.5第一个appium测试............................................................................223
第13章appium基础................................................................................................226
13.1DesiredCapabilities..........................................................................................226
13.2控件定位..........................................................................................................228
13.2.1id定位..................................................................................................229
13.2.2ClassName定位..................................................................................230
13.2.3XPath定位...........................................................................................231
13.2.4Accessibilityid定位............................................................................232
13.2.5Androiduiautomator定位....................................................................233
13.2.6其他定位..............................................................................................234
13.3appium的常用API..........................................................................................235
13.3.1应用操作..............................................................................................235
13.3.2上下文操作..........................................................................................236
13.3.3键盘操作..............................................................................................238
13.3.4触摸操作..............................................................................................238
13.3.5特有操作..............................................................................................241
13.4appiumDesktop................................................................................................243
13.4.1准备工作..............................................................................................243
13.4.2控件定位..............................................................................................245
13.4.3脚本录制..............................................................................................246
第14章appium测试实例.........................................................................................249
14.1appium应用测试.............................................................................................249
14.1.1原生应用测试......................................................................................249
14.1.2移动Web应用测试.............................................................................250
14.1.3混合应用测试......................................................................................252
14.2App测试实战..................................................................................................254
14.2.1安装App..............................................................................................254
14.2.2简单的测试用例..................................................................................255
14.2.3自动化项目设计..................................................................................256