录屏+添加视频到测试报告代码
def record():
file_time = time.strftime("%Y-%m-%d-%H-%M-%S")
file_path = “…/Result_screen/” + file_time + “.mp4”
cmd = “scrcpy -r …/Result_screen/” + file_time + “.mp4”
p = subprocess.Popen(cmd, shell=True)
# p = os.popen(cmd)
yield
os.kill(p.pid, signal.CTRL_C_EVENT)
time.sleep(1)
allure.attach.file(file_path, name=file_time, attachment_type=allure.attachment_type.MP4)
执行操作后进入测试报告中查看,视频大小比本地小一点,并且无法播放
单独添加视频到allure报告中正常,视频为同一份视频
import allure
def test_allure():
print(“这是一个测试用例”)
allure.attach.file(“D:\Programs\AppProject\UI_Framework\Result_screen\2021-03-17-12-04-03.mp4”,
name=“这是一个视频”,attachment_type=allure.attachment_type.MP4)
求解:为什么会出现这个问题