繁体   English   中英

机器人框架 - 如何从报告中读取套件名称、测试用例名称以及跳过消息。html

[英]Robot framework - How to read suite name, test case name along with skip message from report.html

我正在使用“机器人框架”进行自动化测试,如果我在自动化脚本执行过程中遇到任何功能问题,我将创建一个缺陷并通过将缺陷编号作为跳过消息( Skip Defect#001 )。 在解决该缺陷之前,将跳过受影响的测试脚本。

例子:

*** Settings ***
Library    SeleniumLibrary
Library    BuiltIn


*** Test Cases ***
Custom auto scenarios1
    Skip   Defect_001
    Log   Test1

Custom auto scenarios2
    Log   Test2

Custom auto scenarios3
    Log   Test3

Custom auto scenarios4
    Skip   Defect_002
    Log   Test4

报告.html

我有一个要求,我需要从report.html中检索以下信息

  1. 跳过消息( Defect_001Defect_002
  2. 跳过的测试用例名称( Custom auto scenarios1Custom auto scenarios4
  3. 跳过测试可用套件名称( Demo

你能告诉我如何从report.html中检索这些吗

您需要使用机器人 API 并对output.xml文件进行操作。

from robot.api import ExecutionResult, ResultVisitor

class Collector(ResultVisitor):

    def visit_test(self, test):
        if test.skipped:
            print(test.name, test.message, test.parent.name)

es = ExecutionResult("output.xml")
collector = Collector()
es.visit(collector)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM