Skip to content

Instantly share code, notes, and snippets.

@adiralashiva8
Created January 28, 2019 16:12
Show Gist options
  • Save adiralashiva8/c6a524c554da8e2b414fe6342d50785f to your computer and use it in GitHub Desktop.
Save adiralashiva8/c6a524c554da8e2b414fe6342d50785f to your computer and use it in GitHub Desktop.
Robotframework: Get keyword metrics like keyword name, keyword status, total keywords, keywords duration by parsing output.xml using robot.result package (api)
from robot.api import ExecutionResult,ResultVisitor
class KeywordMetrics(ResultVisitor):
def visit_keyword(self,kw):
print "Keyword Name: " + str(kw.name)
print "Keyword Status: " + str(kw.status)
print "Keyword Starttime: " + str(kw.starttime)
print "Keyword Endtime: " + " " + str(kw.endtime)
print "Keyword Elapsedtime (Sec): " + " " + str(kw.elapsedtime/float(1000))
result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
'tag_stat_combine': 'tagANDanother'})
result.visit(KeywordMetrics())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment