一、需要的库
pocoui库
sudo pip3 install pocoui -i https://pypi.tuna.tsinghua.edu.cn/simple
airtest库
pip3 install airtest -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
参考: https://www.bilibili.com/video/BV1bQ4y197Fn/?vd_source=caabcbd2a759a67e2a3de8acbaaf08ea
二、出报告参考下面:(挺多东西的可以参考他其他篇)
https://www.cnblogs.com/songzhenhua/p/16436180.html
录屏和命令执行见下面
https://developer.aliyun.com/article/920762
踩坑记录
如果要用哪个python去跑记得代码顶部要加
from airtest.cli.parser import cli_setup
if not cli_setup():
auto_setup(__file__, logdir=True, devices=["Android:///",])
例子:
# -*- encoding=utf8 -*-
__author__ = "lucax"
from airtest.core.api import *
auto_setup(__file__)
import pymysql
import requests
import time
from airtest.cli.parser import cli_setup
import HTMLTestRunner_cn
import unittest
# 用python的话一定要加这个
if not cli_setup():
auto_setup(__file__, logdir=True, devices=["Android:///",])
class demo(unittest.TestCase):
'''落地页流程'''
@classmethod
def setUpClass(cls):
# 隐式等待
ST.FIND_TIMEOUT=10
def main(self):
"""测试 """
# 预约流程
demo().userMsg()
demo().mobile()
# # 报名流程
# demo().signUpMsg()
# demo().usersign()
if __name__=="__main__":
testunit=unittest.TestSuite()
#添加测试用例到测试套件中
testunit.addTest(demo("main"))
#定义个报告存放路径
filename = './result3.html'
with open(filename, "wb") as file:
#定义测试报告
runner =HTMLTestRunner_cn.HTMLTestRunner(
stream=file,
title=u'网站测试报告',
description=u'用例执行情况:')
# 运行测试用例
runner.run(testunit)
# 在根目录生成报告
from airtest.report.report import simple_report
simple_report(__file__)