Untitled
unknown
plain_text
a year ago
954 B
4
Indexable
# custom_listener.py
from robot.libraries.BuiltIn import BuiltIn
class CustomListener:
ROBOT_LISTENER_API_VERSION = 2 # Use API version 2
def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self
def end_test(self, name, attributes):
if attributes['status'] == 'FAIL':
# Get the test's arguments and keywords used
args = attributes['args']
keywords_used = attributes['keywords']
# Build log message
log_message = "<h2>Test Failed</h2>"
log_message += "<b>Test Name:</b> {}<br>".format(name)
log_message += "<b>Arguments:</b> {}<br>".format(args)
log_message += "<b>Keywords:</b> <ul>"
for keyword in keywords_used:
log_message += "<li>{}</li>".format(keyword)
log_message += "</ul>"
# Log the information with HTML formatting
BuiltIn().log(log_message, html=True)Editor is loading...
Leave a Comment