自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(102)
  • 收藏
  • 关注

原创 linux 离线安装 mysql

mkdir /data/software#cd /data/software注意要将离线文件上传到software目录下tar -xzvfmysql-5.6.33-linux-glibc2.5-x86_64.tar.gz //解压文件mv mysql-5.6.33-linux-glibc2.5-x86_64/ mysql // 重命名mv mysql /usr/local/ //移动文...

2018-03-27 14:31:48 153

原创 pytest 失败截图

@pytest.hookimpl(tryfirst=True, hookwrapper=True)def pytest_runtest_makereport(item, call): outcome = yield rep = outcome.get_result() if rep.when == 'call' and rep.outcome == "failed": driver = getattr(Context, "driver") logg.

2022-11-15 10:03:53 385

原创 python 操作Excel(读取)

# !/usr/bin/env python# -*- coding:utf-8 -*-# Author:victor Liimport openpyxlfrom common.dir_config import DirInfofrom common.elements import Elementclass OpearteExcel: file_name = "" def __init__(self, file_name): self.file_name.

2022-05-07 14:08:54 790

原创 os.path.dirname

#!/usr/bin/env python# -*- coding:utf-8 -*-# Author:victor Liimport osfrom enum import Enumclass DirInfo(Enum): p=os.path.abspath(__file__) root_dir=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# os.path.dirname返回当前目录的上层目录 .

2022-04-18 15:20:58 666

原创 pytest_runtest_protocol

pytest_runtest_protocol获取 当前执行用例 以及下一个用例,内容待完善

2022-03-08 17:32:50 342

原创 appium 定位元素的两种方式

# !/usr/bin/env python# -*- coding:utf-8 -*-# Author:victorimport timefrom appium import webdriverdesired_caps = dict()# 平台desired_caps["platformName"] = "Android"# 系统版本desired_caps["platformVersion"] = "7"# 设备名字desired_caps["deviceNam...

2021-07-20 23:08:26 193 2

原创 adb 常用命令

1、删除已安装的apkadb unistall package #package 是

2021-06-08 23:02:06 85

原创 pytest fixture 当刷scope=class时 类中多个测试方法 返回对象不一致问题

class Test111: @pytest.fixture(scope="class", autouse=True) def get_service(self, session, logger): self.service = EvaluationTeacherService(session, logger) return self.service def test_edit_evaluation(self): print(id(.

2021-05-27 15:00:49 484

原创 pytest pycharm 运行 生成 allure 报告

import pytestimport allurefrom service.item_bank.label.source.source_service import SourceServiceimport [email protected]('随机获取来源下拉框')class TestGetsourceCase: """难度下拉框""" @allure.feature('随机获取来源下拉框') def test_get_region(self,get_url,.

2021-01-11 10:11:10 1301

转载 pytest hook方法总结

钩子函数总结第一部分:setuptools引导挂钩要求足够早注册的插件(内部和setuptools插件),可以使用的钩子pytest_load_initial_conftests(early_config,parser,args): 在命令行选项解析之前实现初始conftest文件的加载。 pytest_cmdline_preparse(config,args): (不建议使用)在选项解析之前修改命令行参数。 pytest_cmdline_parse(pluginmanager,args):

2021-01-06 17:02:20 1627

原创 python 格式化日期输出

import timedef get_time_to_str(str_format='%Y-%m-%d %H:%M:%S'): res = time.strftime(str_format, time.localtime(time.time())) return resdef get_date_as_name(): return get_time_to_str('%Y-%m-%d')

2020-12-15 13:24:21 980

原创 2.2列表推导和生成器表达式

列表推导是构建列表(list)的快捷方式,而生成器表达式则可以用 来创建其他任何类型的序列。如果你的代码里并不经常使用它们,那么 很可能你错过了许多写出可读性更好且更高效的代码的机会2.2.1 列表推导和可读性先来个小测试,你觉得示例 2-1 和示例 2-2 中的代码,哪个更容易读 懂?示例 2-1 把一个字符串变成 Unicode 码位的列表symbols = "$%^^&*"codes = []for symbol in symbols: codes.

2020-12-14 15:26:51 96

原创 关于目录的 枚举化管理

# -*- coding:utf-8 _*-""" @author:victor@time: 2018/12/17 @email:[email protected]@function: 常量"""import osfrom enum import Enumclass DirINfo(Enum): base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # 项目根路径 case_d.

2020-12-07 11:34:30 91

原创 selenium 切换iframe 与嵌套iframe处理

selenium 切换 iframe 方式一共有三种1、通过元素的id 或name属性切换driver,switch_to_frame('') #参数传frame id或者name2、通过元素索引切换#通过索引切换 注意索引从0开始 注意 只有同级可以使用 索引切换 如果是嵌套的frame 是不能使用索引切换的driver.switch_to.frame(1)3、通过定位元素的方式切换driver.switch_to.frame(driver.find_elements.

2020-11-05 23:28:56 2796

原创 selenium 下载文件

from selenium import webdriveroptions = webdriver.ChromeOptions()# download.default_directory 默认下载路径# profile.default_content_settings.popups 为0时不会打开保存询问对话框prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'd:\\'}o.

2020-11-03 23:03:13 1559

原创 appium demo 定位 智能等待及滑动元素

from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.wait import WebDriverWaitimport selenium.webdriver.support.expected_conditions as ECimport unittestfrom appium import webdriverdef element_to_be_clickable(driver, location=N.

2020-10-29 14:26:27 140

原创 第二章序列的数组之 内置序列类型概览

容器序列: list、tuple 和 collections.deque 这些序列能存放不同类 型的数据扁平序列   str、bytes、bytearray、memoryview 和 array.array, 这类序列只能容纳一种类型。 容器序列存放的是它们所包含的任意类型的对象的引用,而扁平序列 里存放的是值而不是引用。序列类型还能按照能否被修改来分类可变序列  list、bytearray、array.array、collections.deque ...

2020-10-28 14:17:51 147

原创 python中万能的%r

from math import hypotclass Vector: def __init__(self, x=0, y=0): self.x = x self.y = y def __repr__(self): return 'Vector(%r, %r)' % (self.x, self.y)#输出结果Vector([1, False, {'key': 'val'}, (1, 2, 3)], ['2', '3', '4']) .

2020-10-16 09:04:03 1560

原创 第1章:Python 数据模型

目录1、一摞Python风格的扑克牌2、向量3、xxxx4、zzzzzzzzzzzzzzzzz1、一摞Python 风格的扑克牌#!/usr/bin/python# -*- coding: UTF-8 -*-# @Time : 2020/10/15 14:43# @Author : victor# @Email : [email protected]"""数据模型其实是对 Python 框架的描述,它规范了这门语言自身构建模块的接口,

2020-10-15 17:33:05 377

原创 selenium js 滑动滚动条

from selenium import webdriveroption = webdriver.ChromeOptions()option.add_experimental_option('useAutomationExtension', False)option.add_experimental_option('excludeSwitches', ['enable-automation'])# 打开chrome浏览器driver = webdriver.Chrome(options=o.

2020-10-14 22:13:28 457

原创 selenium js 点击

ele=driver.find_element_by_id("123")driver.execute_script("arguments[0].click()",ele)

2020-10-14 21:35:42 1071

原创 selenium css 定位器常用方式

更多参考w3c

2020-10-14 00:11:50 103

原创 python requests 上传word

2020-09-29 17:59:32 520 1

原创 pytesfixture 使用 pytest.mark.parametrize参数化的数据

2020-09-16 15:41:44 216

转载 pytest 一旦失败跳过后面的测试(官网看的)

from typing import Dict, Tupleimport pytest# store history of failures per test class name and per index in parametrize (if parametrize used)_test_failed_incremental: Dict[str, Dict[Tuple[int, ...], str]] = {}def pytest_runtest_makereport(item, ca..

2020-09-08 11:18:27 1140

原创 python 隐式等待与显示等待

隐式等待:隐式等待 10秒钟from selenium import webdriveroption = webdriver.ChromeOptions()option.add_experimental_option('useAutomationExtension', False)option.add_experimental_option('excludeSwitches', ['enable-automation'])# 打开chrome浏览器driver = webdrive

2020-09-07 22:53:58 3066

原创 pytest_addoption 动态添加命令行参数并获取,与 自定义跳过某些标记的测试(pytest_collection_modifyitems)

conftest.pydef pytest_configure(config): config.addinivalue_line("markers", "slow: mark test as slow to run") config.addinivalue_line("markers", "victor: mark test as slow to run") # 与pytest.ini 中一样就是注册一下但是仍可以使用未定义的标记def pytest_addoption(par.

2020-09-07 15:35:09 1915 4

原创 pytest capfdbinary,capys捕获异常

"""如果被测代码写入非文本数据,则可以使用capsysbinary固定装置捕获该数据,而不是bytes从readouterr方法返回。如果被测代码写入非文本数据,则可以使用capfdbinary固定装置捕获该数据,而不是bytes从readouterr方法返回。该capfdbinary夹具上的文件描述符级别运行。"""def test_myoutput(capfdbinary): # or use "capfd" for fd-level print("hello") .

2020-09-07 11:22:02 420

原创 selenium 常用定位方式

from selenium import webdriveroption = webdriver.ChromeOptions()option.add_experimental_option('useAutomationExtension', False)option.add_experimental_option('excludeSwitches', ['enable-automation'])# 打开chrome浏览器driver = webdriver.Chrome(options=o.

2020-09-02 22:59:36 101

原创 pytest 内置 fixtures 之 cache:使用 cache 写入、读取 pytest 缓存

#!/usr/bin/python# -*- coding: UTF-8 -*-# @Time : 2020/8/31 11:29# @Author : victor# @Email : import pytestimport timefrom _pytest.fixtures import SubRequestdef expensive_computation(): print("running expensive computation....

2020-09-02 17:45:15 554

原创 pytest 一些常用插件

用例失败后自动重新运行:pytest-rerunfailures,使用方法: 安装插件:pip install pytest-rerunfailures pytest test_x.py --reruns=n (失败后重运行的次数) 重复运行测试:pytest-repeat,使用方法: 安装插件:pip installpytest-repeat pytest test_x.py --count=n (重复运行的次数) 多线程执行测试任务:pytest-xdist,使用方法: 安装.

2020-09-02 16:30:56 744

原创 pytest 的常见参数:

-m :只运行被标记的测试用例; -k:只运行与给定字符串表达式匹配的测试用例; -s :显示标准输出,例如print()的语句; -v :显示详细报告; -q :显示简洁报告; -x :用例失败时立即停止测试; -c file :从 file 加载配置文件; -l (--showlocals) :用例失败信息回溯时显示局部变量及其值; -rsxX :报告(r)测试用例被跳过(s)、预计失败(x)、预计失败但实际通过(X)的原因; -strict:禁止使用未在配置文件(pytest...

2020-09-02 16:26:37 3206

原创 xpath 定位

xpath 中 /html 代表绝对路径 从html节点开始寻找/html/body//textarea 代表 相对路径 从htm/body/ 下任意textarea

2020-09-02 00:14:08 300

原创 selenium 隐藏被浏览器被自动化工具控制横幅的

from selenium import webdriveroption = webdriver.ChromeOptions()option.add_experimental_option('useAutomationExtension', False)option.add_experimental_option('excludeSwitches', ['enable-automation'])# 打开chrome浏览器driver = webdriver.Chrome(options=o.

2020-08-31 22:29:23 1020

原创 pytest批量执行

import pytestimport ospath = os.path.dirname(__file__)path = path + "/report/"pytest.main(["-s","--alluredir={}".format(path), "cases"])#运行 cases下所有测试用例result = os.system(r"allure serve {}".format(path))print("result={}".format(result).

2020-08-31 11:16:46 2076

原创 pytest conftest 获取case中的变量

smtpserver="www.baidu.com"#case中有该变量确保能获取到@pytest.fixture(scope="session")# @contextlib.contextmanagerdef connect(): # raise RuntimeError("12312") print("yield 之前") yield Foo(1, 2) ... # close connection print("yield 之后")def tes.

2020-08-13 16:06:23 1232

原创 使用functools.partial 绑定函数/预设参数值

def sub(x, y): return x - y def attach_wrap(func1, func2=None): if func2 is None: return functools.partial(attach_wrap, func1)#返回attach_warp(sub,*args,*kwargs) setattr(func1, func2.__name__, func2) retu...

2020-08-13 15:31:01 276

原创 pytest夹具完成/执行拆卸代码

@contextlib.contextmanagerdef connect(port): print("yield 之前") yield Foo(1,2) ... # close connection print("yield 之后")@pytest.fixturedef equipments(request): r = [] for port in ("C1", "C3", "C28"): cm = connect(port).

2020-08-13 14:44:53 189

原创 pytest 间接参数化

2020-08-12 16:33:11 110

原创 pytest_assertrepr_compare 自定义失败的断言解释

test_login.pyconftest.py

2020-08-12 14:54:51 715

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除