关于测试:0315-截图日志与录屏

截图

def screenshot(self, file):
    """封装截图办法"""
    self.driver.save_screenshot(file)
        
### allure 获取截图
allure.attach(picture, attachment_type=allure.attachment_type.PNG)

日志

import logging

# 增加日志
logging.info("start find : \nargs: " + str(args) + "\nkwargs: " + str(kwargs))

联合 pytest.ini 文件应用

[pytest]
addopts = -sv --log-cli-level=INFO

录屏

应用第三方工具 scrcpy,次要思考的是,应用 appium 录屏,无奈获取局部手机的受权

GitHub 地址

https://github.com/Genymobile…

应用教程

https://blog.csdn.net/was172/…

将录屏的性能封装到 conftest.py 中

import os
import signal
import subprocess

import pytest


@pytest.fixture(scope="function", autouse=True)
def scrcpy_record():
    cmd = "scrcpy --record file.mp4"
    p = subprocess.Popen(
        cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
    )
    print(p)
    yield
    os.kill(p.pid, signal.CTRL_C_EVENT)

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理