截图

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 osimport signalimport subprocessimport 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)