简体   繁体   中英

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

I am using "Robot Framework" for my automation testing, if I am facing any functional issues as part of my Automation script execution, I will create a defect and skip that test case by giving the defect number as a skip message( Skip Defect#001 ). Until that defect is resolved, the affected test script is skipped.

Example:

*** 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

report.html

I have a requirement where I need to retrieve the following information from report.html

  1. Skip message ( Defect_001 & Defect_002 )
  2. Skipped Test Case Name ( Custom auto scenarios1 & Custom auto scenarios4 )
  3. Skipped test available Suite name ( Demo )

Can you please tell me how to retrieve these from report.html

You need use robot API and operate on output.xml file.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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