自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 删除手机所有三方应用

删除手机所有三方应用。

2023-03-27 17:02:41 138

原创 yaml接口自动化实战(2)

import yamlclass YamlUtil: def __init__(self,yaml_file): """ 通过 init方法把yaml文件传入到这个类 :param yaml_file """ self.yaml_file=yaml_file def read_yaml(self): """ 读取yaml,对yaml反序列化,就是把yaml格式转换成dict格式

2021-07-06 23:59:14 338

原创 Yaml介绍(一)

#1、用于全局的配置文件 ini/yaml#2、用于写测试用例(接口测试用例)#yaml简介: yaml是一种数据格式,支持注释,换行,多行字符串,裸字符串(整形,字符串)#语法规则:#1、区别大小写#2、使用缩进表示成绩,不能使用tab键缩进,只能使用空格(和pathon一样)#3、缩进没有数量,只要前面是对齐的就行#4、注释是##----------------------------------#数据组成#1、Map对象,键值对 键:(空格)值#多行写法#msxy:

2021-07-06 23:53:28 419

原创 Pytest.mark.parametrize()

#@ pytest.mark.parametrize(args_name,args_value)#args_name 参数昵称#vaule:参数值(列表,元组,字典列表,字典元组),有多个值用例就会执行多少次第一种方式import pytest,osclass Testapi(): @pytest.mark.parametrize('args',['花木兰','凯','苏烈']) #结果 花木兰 凯 苏烈 #@pytest.mark.parametrize('args'

2021-07-06 23:25:46 258

转载 pytest文档5-fixture之conftest.py

前面一篇讲到用例加setup和teardown可以实现在测试用例之前或之后加入一些操作,但这种是整个脚本全局生效的,如果我想实现以下场景:用例1需要先登录,用例2不需要登录,用例3需要先登录。很显然这就无法用setup和teardown来实现了。这就是本篇学习的目的,自定义测试用例的预置条件fixture优势1.firture相对于setup和teardown来说应该有以下几点优势命名方式灵活,不局限于setup和teardown这几个命名 conftest.py配置里可以实现数据共享,不需.

2021-07-01 18:26:59 118

原创 smoke

pytest -vs -m “smoke” #执行装饰器带smoke的用例 -vs可以不加 pytest.ini配置文件已经加了pytest -vs -m “smoke or usermange” #执行装饰器带smoke 和 username 的用例import pytestclass TestLogin(): age=18 def setup(self): print("\n这是执行前的用例") def test_06_qianghong2(sel

2021-06-29 23:50:08 159 2

原创 pytest前置和后置

setup/teardowm,setup_class/teardowm_classsetup 在每个用例之前执行一次teardown 在每个用例之后执行一次setup_class这个在所有用例之前只执行一次(在每个类执行前的初始化工作,比如创建日志对象,创建数据库的连接,创建接口的请求对象)teardowm_class 这个在所有用例之后只执行一次(在每个类执行后的初始化工作,比如销毁日志对象,销毁数据库的连接,销毁接口的请求对象)这两种方法可以混合使用,例如setup搭配teardown_

2021-05-14 22:47:15 322

原创 一、Pytest简介和插件库

1、Pytest 简介1、pytest是一个非常成熟的pytest的单元框架2、pytest可以和selenium、requests、appnium完成web自动化、接口自动化、app自动化3、pytest可以实现测试用例的跳过以及return失败用例重跑4、pytest可以和allure生成非常美观的测试报告5、pytest可以和jmeter持续集成6、pytest有非常多强大的插件(1)、 pytest-html 生成html格式的自动化测试报告(2)、pytest-xdist 测试用例

2021-05-13 22:44:42 444

原创 Pytest测试用例的执行方法

如下是目录结构:1、主函数模式(1)运行所有 pytest.main()(2)指定模块 pytest.main(’[-vs],’,’./testcase/test_day1.py’)(3)指定目录pytest.main(’[-vs]’),’./testcase’)(4)通过nodeid指定用例运行:nodeid由模块名,分隔符,类名,方法名,函数名组成#pytest.main(["-vs"],’./interface_testcase/test_day3.py::test_demo11’)#

2021-05-13 22:40:22 1058 6

原创 ordering插件改变用例执行顺序

前提:安装pytest-ordering 插件,可用于改变测试用例的执行顺序1、unittest执行顺序 根据assii码进行执行2、pytest 从上到下依次执行 pytest.mark.run(order=2) 使用mark标记,改变默认的执行顺序,未装饰的使用默认的从上到下执行实例:import pytestclass TestLogin(): def test_06_qianghong2(self): print("我是杨强弘六号") @pytest

2021-05-13 22:33:48 120

原创 二、markers 分组测试

七、如何分组执行(冒烟,分模块执行,分接口和web执行)#需要执行的用例使用装饰器进行装饰,关键字可以自定义,在pytest.ini处需要声明 markers[pytest]addopts=-vstestpaths=./python_files=test_*.pypython_classes=Test*python_functions=testmarkers=smoke:冒烟用例 usermange:用户管理模块 productmanage:商品管理模块目

2021-05-13 22:29:36 115

原创 simple和Loghtml

报告的目录:主程序的路径:C:\Users\admin、\Downloads\AirtestIDE-win-1.2.5\AirtestIDE\case.air\Demo.air\Demo.pysimple_report 生成报告#-*- encoding=utf8 -*-__author__ = "admin、"from airtest.core.api import *from airtest.report.report import simple_reportfrom airtest.

2021-04-30 17:45:36 106 1

原创 抖音分身

添加分身__author__ = "admin、"from time import sleepfrom airtest.core.api import *from poco.drivers.android.uiautomation import AndroidUiautomationPocopoco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)auto_setup(__file_

2021-04-29 09:23:38 316

原创 airtest 截图和多图查找

# -*- encoding=utf8 -*-__author__ = "yangqianghong"from airtest.aircv import *from airtest.core.api import *from airtest.cli.parser import cli_setupfrom airtest.core.settings import Settings as STfrom poco.drivers.android.uiautomation import Android

2021-04-29 09:23:01 1921

原创 zipfile压缩

import zipfiledef zipDir(dirpath,outFULLName): zip=zipfile.ZipFile(outFULLName,'w',zipfile.ZIP_DEFLATED) for path,dirnames,filenames in os.walk(dirpath): fpath=path.replace(dirpath,"") for filename in filenames: zip.wri

2021-04-26 14:08:29 2258

原创 airtest封装的滑动

from airtest.core.api import *from airtest.report.report import simple_reportfrom airtest.report.report import LogToHtmlfrom poco.drivers.android.uiautomation import AndroidUiautomationPocofrom airtest.core.helper import Gfrom airtest.core.android.adb

2021-04-25 10:50:56 426

原创 ADB

# -*- coding: utf-8 -*-import osimport sysfrom time import sleepfrom random import randintclass Event(object): def __init__(self): '''常用keyevent事件''' self.KEYCODE_HOME = 3 # home键 self.KEYCODE_MENU = 82 # 解锁 sel

2021-04-21 17:43:44 147

原创 HTMLTestRunner生成测试报告

用例执行完成后,执行结果默认是输出在屏幕上,其实我们可以把结果输出到一个文件中,形成测试报告。unittest自带的测试报告是文本形式的,如下代码:import unittestimport os#测试用例目录test_dir=os.path.dirname(os.path.abspath(__file__))#加载测试用例disvover=unittest.defaultTestLoader.discover(test_dir,pattern="test_Suite.py")#测试报告

2021-04-20 18:22:25 470

原创 discover执行多个用例

前面我们说了,对于不同文件用例,我们可以通过addTest()把用例加载到一个测试套件(TestSuite)来统一执行,对于少量的文件这样做没问题,但是如果有几十上百个用例文件,这样做就太浪费时间了。unittest中的discover()方法可以批量加载用例discover(start_dir, pattern=‘test*.py’, top_level_dir=None)start_dir:测试模块名或测试用例所在目录pattern=‘test*.py’:表示用例文件名的匹配方式,此处匹配的是以

2021-04-19 18:10:42 161

原创 荣耀体验门店

# import json# import requests# #url="https://openapi.vmall.com/mcp/offlineshop/getShopList" #https://m.vmall.com/help/hnrstoreaddr.htm# url="https://openapi.vmall.com/mcp/offlineshop/getShopList"## heardes={"Mozilla/5.0 (Windows NT 10.0; Win64; x

2021-04-19 17:58:00 111

原创 cls和self的区别

注意cls和self的区别class A(object): a = 'a' @staticmethod def foo1(name): print 'hello', name print A.a # 正常 print A.foo2('mamq') # 报错: unbound method foo2() must be called with A instance as first argument (got str instance

2021-04-19 15:58:22 87

原创 Unittest_assert

常用断言方法import unittestclass Test(unittest.TestCase): def test_01(self): print('判断a是否存在b中') a = '安静' b = '测试安静' self.assertIn(a, b) def test_02(self): print('判断a是否等于b') a = '111' b =

2021-04-18 23:48:56 99

原创 Unittest_skipe

# 在执行测试用例时,有时候有些用例是不需要执行的,那我们怎么办呢?难道删除这些用例?那下次执行时如果又需要执行这些用例时,又把它补回来?这样操作就太麻烦了。## unittest提供了一些跳过指定用例的方法## @unittest.skip(reason):强制跳转。reason是跳转原因# @unittest.skipIf(condition, reason):condition为True的时候跳转# @unittest.skipUnless(condition, reason):condi

2021-04-18 23:46:33 122

原创 Unittest_suite

#Test Suite简称测试套件,就是可以将不同的用例都添加到这个套件中,然后通过执行套件,然后完成执行测试用例。# 在前面一章中示例了如何编写一个简单的测试,但有两个问题:## 我们知道测试用例的执行顺序是根据测试用例名称顺序执行的,在不改变用例名称的情况下,我们怎么来控制用例执行的顺序呢?# 一个测试文件,我们直接执行该文件即可,但如果有多个测试文件,怎么进行组织,总不能一个个文件执行吧?# 要解决上面两个问题,我们就要用到测试套件(TestSuite)了import unittes

2021-04-18 23:44:41 180 1

原创 selenium爬取药监总局

url="http://125.35.6.84:81/xk/"from selenium import webdriverfrom lxml import etreefrom time import sleeppage_text_list=[]driver=webdriver.Chrome()driver.get("http://125.35.6.84:81/xk/")sleep(1)page_text=driver.page_sourcepage_text_list.append(p

2021-04-14 00:40:07 471

原创 yagmail—邮件发送

import yagmail# 连接邮箱服务器email = yagmail.SMTP(user="[email protected]", password="slycewbmwqzrfhbj", host="smtp.qq.com",# smtp服务器,每个邮箱各不相同,请自行百度 port=465)# 服务器端口,自行百度# 发送一份简单的邮件email.send(t.

2021-04-14 00:17:55 472 1

原创 详解OS模块路径问题

import osconf_path = os.path.dirname(os.path.abspath(__file__))work_path = os.path.dirname(os.path.dirname(conf_path))data_path = os.path.join(work_path, "data")print(conf_path)print(work_path)print(data_path)print(os.path.abspath(os.path.dirname(os

2021-03-29 16:05:41 228 1

原创 应用启动速度

# -*- encoding=utf8 -*-__author__ = "yangqianghong"from airtest.core.api import *import logginglogger = logging.getLogger("airtest")logger.setLevel(logging.ERROR)from airtest.cli.parser import cli_setupfrom airtest.core.android import androidfrom

2021-03-26 21:32:12 126

原创 项目路径

# -*- coding: utf-8 -*-# @File : ProjectPath.py# @Author: Zhaoziqi# @Date : 2021/2/18# @Desc :import globimport osclass ProjectPath: """项目路径""" def __init__(self): self.basedir = os.path.abspath(os.path.dirname(os.path.dirname(

2021-03-26 21:25:07 98

原创 设备滑动(上下,左右)

# -*- encoding=utf8 -*-import osimport timefrom random import choicezuohua=("100 810 550 810")youhua=("550 810 100 810")s=(zuohua,youhua) #不可用count=0for i in range(10000): time1 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())

2021-03-26 21:24:24 169

原创 Case2 个人路径

# -*- encoding=utf8 -*-__author__ = "admin、"from airtest.core.api import *from airtest.report.report import simple_reportfrom airtest.report.report import LogToHtmlfrom airtest.core.helper import Gfrom threading import Threadfrom random import randi

2021-03-26 21:22:42 221

原创 Airtest一些方法

https://mp.weixin.qq.com/s?__biz=MzUxMDc4NTkwMA==&mid=2247484579&idx=1&sn=950ebd07b063674b3a1f5f6ae2abe768

2021-03-26 21:21:31 690

原创 Case1公司路径

# -*- encoding=utf8 -*-__author__ = "admin、"from airtest.core.api import *from poco.drivers.android.uiautomation import AndroidUiautomationPocoauto_setup(__file__)poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)

2021-03-26 21:20:08 186

原创 Selenium常见问题

selenium 问题:加了显性等待后,操作元素依然出错背景: 用WebDriverWait时,一开始用的是presence_of_element_located,我对它的想法就是他就是用来等待元素出现。结果屡屡出问题。元素默认是隐藏的,导致等待过早的就结束了。解决:去StackOverFlow查了一下,发现我应该用visibility_of_element_located。原文:复制代码复制代码Well, I would guess that presenceOfElementLocated

2021-03-26 21:18:55 233

原创 Selenium问题

**1、遇到style=“display: none”方法一:后来检查了一下发现display:none,这是一个css设置,可以让模块不显示在这里插入图片描述经过一翻查询发现可以用selenium执行js代码来修改css经过一翻查询发现可以用selenium执行js代码来修改css# 一页20个数据for x in range(20): # 根据类来定位元素,必须加序号不然报错 js = "document.getElementsByClassName('left f16')

2020-11-22 17:22:33 108

原创 jenkins自动化发布版本

# -*- coding: utf-8 -*-from selenium.webdriver import Chromefrom time import sleepfrom selenium.webdriver.chrome.options import Options #对浏览器设置作修改import jsonimport datetime,timefrom selenium.webdriver.support.ui import Selectdrivers_path = "D:\P

2020-11-13 16:21:06 381

原创 Selenium各模块和方法

1、selenium expected_conditions 模块解析https://www.jianshu.com/p/7f0d85fbba13?utm_campaign=maleskine#coding=utf-8from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECfrom

2020-10-12 23:03:16 298

原创 魔法方法

1、 __init"""init 指魔法方法 初始化对象 给对象赋予初始属性 无法更改ps:__init__() 在创建对象时会自动调用 不需要手动调用def __init__(self) 中的self参数 不需要传递 python解释器会自动把当前对象的引用进项传递传递"""# class Wash():# def __init__(self): #魔法方法# pass# self.height=800# self.widt

2020-09-29 22:20:01 139

原创 python_继承

单继承class A: def __init__(self,num): self.num=num def __str__(self): return f"{self.num}的值"b=A(10)print(b)class shifu(object): def __init__(self): self.gongfu='古法煎饼果子' def tudi1(self): print(f"{self.gon

2020-09-29 22:18:51 79

原创 面向对象—继承、私有属性

1、单继承# class A:# def __init__(self,num):# self.num=num# def __str__(self):# return f"{self.num}的值"## b=A(10)# print(b)""""体验继承"""#定义子类 定义父类 创建对象 验证# class A(object):# def __init__(self):# self.num=1# de

2020-09-23 00:20:36 151

空空如也

空空如也

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

TA关注的人

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