08 2020 档案
摘要:一 安装前准备: Jdk下载,建议jdk1.8以上: 清华大学镜像站 https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/8/jdk/x64/windows/ 2. Jenkins安装包: https://www.jenkins.io/download
阅读全文
摘要:前言 使用 allure 生成的报告,层次分明 我们借助上篇博客生成的报告,来认识下allure报告结构 Suites 结构 不同颜色方框代表不同状态 红色 failed 绿色 passed 黄色 error 灰色 skip 紫色 xfail 2. suite 结构分类: 模块名-函数用例\类函数用
阅读全文
摘要:allure官方文档 https://docs.qameta.io/allure/ allure framework 官方介绍 Allure Framework是一种灵活的轻量级多语言测试报告工具,它不仅可以以简洁的网络报告形式非常简洁地显示已测试的内容,而且还允许参与开发过程的每个人从日常执行中提
阅读全文
摘要:练习: 一个整数,它加上100后是一个完全平方数,加上268又是一个完全平方数,该数是多少? 分析: 1)将该数加上100后开方,得到整数x,加上268再开方,得到整数y,需要用到math.sqrt() 代码: import math for num in range(100000): # x、y
阅读全文
摘要:练习: 企业发放的奖金根据利润提成: 利润低于或等于10万元时,奖金可提10%; 利润10-20万元之间,低于10万元的部分按10%提成,高于10万元的部分按7.5%提成; 利润20-40万元之间,高于20万部分按照5%提成; 利润40-60万元之间,高于40万部分按照3%提成; 利润60-100万
阅读全文
摘要:习题: 有1、2、3、4四个数字,能组成多少个互不相同且无重复的三位数?都是多少,用列表取出来? 分析: 1、取出(1、2、3、4)可以组成三位数的不同种数 2、去除重复的三位数 3、存入列表 代码: # 1、(1、2、3、4)可以组成三位数的不同种数 resList = [] for i in r
阅读全文
摘要:需求: 有如下URL地址,截取出 ?后面的参数,并将参数以 ‘key:value’ 的键值对形式保存。 url="http://xx.xx.xx:8000/get_account.json?page_size=20&page_index=1&user_id=456" 解法1(利用split()函数)
阅读全文
摘要:需求: 输出 1/1+1/3+1/5+...+1/99 的值。 解法1: sum = 0 list_1=[] for i in range(1, 100): if i % 2 == 1: sum += 1/i list_1.append(i) print('%.2f\n%s'%(sum, list_
阅读全文
摘要:1、文件的作用 存储数据,读写文件是最常见的 I/O 操作 2、打开和关闭文件 # 步骤: # 1)打开文件,获取文件描述符 # 2)操作文件描述符-->读/写 # 3)关闭文件close()-->文件读写完成后应该及时关闭:1、占用资源;2、数据丢失 f = open('test.txt', 'r
阅读全文
摘要:前言: # 函数参数中存在两种特殊的参数,动态参数 *args、关键字参数 **kwargs。 # 在一个函数里面只能有一个动态参数、关键字参数,可以同时存在形参、默认参数、动态参数、关键字参数 # 动态参数 *args、关键字参数 **kwargs 常用做不定长的输入。 动态参数示例代码: # 动
阅读全文
摘要:1、目的: 解决多个assert断言中,其中一个断言失败,后续断言不再继续执行的问题。 2、使用插件: pytest-assume 3、安装: pip install pytest-assume -i https://pypi.tuna.tsinghua.edu.cn/simple 4、assert
阅读全文
摘要:插件:pytest-html github源码: https://github.com/pytest-dev/pytest-html 安装: pip install pytest-html -i https://pypi.tuna.tsinghua.edu.cn/simple 执行: 命令行执行:
阅读全文
摘要:安装: pip install pytest-rerunfailures -i https://pypi.tuna.tsinghua.edu.cn/simple 环境要求: Python 3.5, 最高 3.8, or PyPy3 pytest 5.0或更高版本 参数: 命令行参数:--reruns
阅读全文
摘要:1、pytest.ini的放置位置: 一般放在项目工程的根目录(即当前项目的顶级文件夹下),名字不能更改 2、pytest.ini的作用: 指定pytest的运行方式(命令行窗口输入pytest后,会读取pytest.ini中的配置信息,按配置的方式去运行) 3、cmd下使用 pytest -h 命
阅读全文
摘要:当存在多套测试环境时,通过自定义命令行参数,快速切换host 查看pytest系统命令行参数:pytest -h 1、编辑 conftest.py: import os import pytest def pytest_addoption(parser): '''增加命令行参数 --cmdhost'
阅读全文
摘要:设计思路:设计用例时,如果用例执行失败,则标记 xfail,所有引用该用例的其他用例,均调用该 xfail 标记 示例: # File : test_demo_16.py # IDE : PyCharm import pytest @pytest.fixture(params=[{'user': '
阅读全文
摘要:skip跳过用例: 跳过意味着你希望只在满足某些条件时测试才能通过,否则pytest应该跳过该测试。 常见的例子是跳过非windows平台上的仅windows测试,或者跳过依赖于当前不可用的外部资源(例如数据库)的测试。 # File : test_demo_15.py # IDE : PyChar
阅读全文
摘要:pytest.raises() 函数文档如下: def raises( # noqa: F811 expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]], *args: Any, **kwargs: Any ) -> Union["
阅读全文
摘要:在用例设计中,总会发生异常,甚至判断抛出的异常是否符合预期,可以使用两种异常断言的方式: 1)使用 try...except...else... 接收异常 2)使用 pytest.raises(typeException) 接收异常 # File : test_demo_12.py # IDE :
阅读全文
摘要:断言: 将实际结果与预期结果进行比对。 pytest 使用 python 标准 assert 进行断言,assert 格式: assert expression [, arguments]# expression 为 True 则 pass# expression 为 False 则 抛出异常,有
阅读全文
摘要:xfail 函数文档如下: def xfail(self,condition=None, reason=None, raises=None, run=True, strict=False): """mark the the test function as an expected failure i
阅读全文
摘要:本篇博客比较下 parametrize 中 参数分别为 True 和 False 时的两种情况: 1) 当 indirect=False 时,argnames 参数被当成普通变量 import pytest@pytest.fixture(params=['a', 'b', 'c'])def fixt
阅读全文
摘要:IDE界面操作 录制:红色录制按钮处于按下状态 回放:由于网络延迟原因,回放速度切换最低 fast >>> slow 全部回放: 回放选中元素: 浏览器:回放时,浏览器处于打开状态 IDE 脚本编辑 修改:在 Table 标签下选中某一行命令,修改 Command、Target、Value 即可 新
阅读全文
摘要:问题:在验证 parametrize 源码的时候,发现传入 ids 中文 id 后,出现如下编码问题: # File : test_demo_10.py # IDE : PyCharm import pytest def division(a, b): return int(a / b) @pyte
阅读全文
摘要:parametrize 允许在测试函数或类中定义多组参数和fixturesparametrize 函数文档如下: def parametrize(self,argnames, argvalues, indirect=False, ids=None, scope=None): """ Add new
阅读全文
摘要:1、源码解释如下::arg autouse: if True, the fixture func is activated for all tests that can see it. If False (the default) then an explicit reference is need
阅读全文
摘要:1、本文介绍,如何利用 fixture 的 params、ids 参数,实现前置条件参数化 使用 @pytest.fixture(param=[list1, list2, list3]) 的方式,以 request.param 的方式作为返回值供测试函数调用,param 中有多少元素,则调用几次,分
阅读全文
摘要:conftest.py: 1)专门存放 fixture 的文件 2)conftest.py 可以存放多个 fixtures 3)conftest.py 文件名称是固定的,不能改变 4)conftest.py 只对同一个 package 下的用例生效 5)不同目录可以有自己的 conftest.py,
阅读全文
摘要:1、新建文件夹时,如果存在 __init__.py 文件,IDE 会自动识别成 module package 2、python __init__.py 作为包必不可少的一部分,提供了可初始化的配置,可以简化 module package 的导入操作 2.1 有如下目录结构,使用 tree /F 命令
阅读全文
摘要:1、fixture 作用 1)测试用例执行的环境准备工作和清理,在 unittest 中指 setUp(),tearDown() 2)提供一种可靠和可重复性的手段去运行哪些基本的测试内容,比如登录和退出,使用fixture只用做一次。 2、固定目录 conftest.py 1)固定目录,不可更改,每
阅读全文
摘要:1、setup\teardown 运行级别 模块级别(setup_module/teardown_module):开始于模块始末,全局的 函数级(setup_function/teardown_function):对函数用例生效(不在类中) 类级(setup_class/teardown_class
阅读全文
摘要:直接上代码吧~~~~ # File : test_demo_2.py # IDE : PyCharm import pytest def setup_function(): print('*' * 10 +'用例开始!'+ '*' * 10) def teardown_function(): pri
阅读全文
摘要:pytest 官方API说明:https://docs.pytest.org/en/latest/reference.html 1、pytest安装: pip install -U pytest -i https://pypi.tuna.tsinghua.edu.cn/simple 2、pytest
阅读全文
摘要:demo 5 # Databaselibrary 安装:pip install robotframework-databaselibrary -i https://pypi.tuna.tsinghua.edu.cn/simple # Databaselibrary 在线文档:http://franz
阅读全文
摘要:demo3 # 执行计算器程序 # run C:\personal\npp.7.8.9.bin.x64\notepad++.exe run calc.exe # 等待窗口出现 win wait active | [ WindowTitle | WindowText=WindowText | Time
阅读全文
摘要:1、将下面代码保存为 upload_file.html <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <title>upload_file</title> <link href="h
阅读全文
摘要:AutoIt下载地址:https://www.autoitscript.com/site/autoit/downloads/ SciTE Script Editor 脚本编写工具 AutoIt中文在线手册:https://www.jb51.net/shouce/autoit/ 1、AutoIt介绍
阅读全文
摘要:本来计划是使用 robot 实现上传,结果开机就入坑。 坑1:运行 ride 报错:timer can only be started from the main thread。 1)环境: widows_server2019_x64 python 3.7.8 wxpython 4.1.0 ride
阅读全文
摘要:1、什么是po? page object,页面即对象,将一个实现过程分成不同层。 2、po设计的好处 1)代码复用,节省代码量 2)并行开发,每个page互不影响,提高开发效率 3)测试对象和测试用例分离,维护方便 3、po设计原理 每个页面单独设计成一个类,页面中的元素作为属性,对元素的操作作为方
阅读全文
摘要:1、Selenium2Library的版本支持,参照官网http://robotframework.org/SeleniumLibrary/(版本不支持会有意想不到的惊喜噢) 1)Selenium2Library对python和selenium某一版本的支持是依赖seleniumlibrary版本的
阅读全文
摘要:1、构建项目 add suite 时格式选择 txt,页面报错 [ ERROR ] Suite 'Test Projects' contains no tests matching name 原因: 应该是run程序的执行环境不识别txt文件 解决办法: add suite 时格式选择 robot
阅读全文
摘要:记录第一天用robotframework遇到的大坑~~~ 1、robotframework 环境(pip list): python 3.8.2 robotframework 3.1.2 wxpython 4.1.0 ride 1.7.4.2 2、python shell 运行 ride >>> f
阅读全文

浙公网安备 33010602011771号