How to Remove Warning from robot output file

Is there any way I can remove this error warning from my robot output file.

I think that there are no options for that.

What you can do is to remove those XML elements from output.xml and then use rebot to remake the log and report.

cd <directory where output.xml>
rebot output.xml
1 Like

Hi Veda,

It’s quite simple, you update your test case, find the keywords in the documentation that are deprecated, read what the documentation tells you is the keyword you should use now and update (maintain) your test case.

The warnings are there for a reason, if you ignore them and don’t maintain your tests they will break at some point in the future, better to do the maintenance now when you are just getting these annoying warnings than later when the tests are failing and your project is in a rush to get the release done.

Actually if you read the warnings, they even tell you what you need to do to remove them

Please use ________ instead

I’ll step off my soapbox now.

Dave.

4 Likes

I would totally second Daves recommendation!!

Fix the usage of the deprecated keyword.

The following is NOT recommended, but possible.

However there are possibilities to remove them from the output.xml
I wrote the following thing once two years aho.

Create a WarningRemover.py

from robot.api import ExecutionResult, ResultVisitor
from robot.reporting.resultwriter import ResultWriter
from robot.conf.settings import RebotSettings
​
​
class WarningRemover:
​
    ROBOT_LISTENER_API_VERSION = 3
​
    @staticmethod
    def output_file(original_output_xml):
        result = ExecutionResult(original_output_xml)
        result.visit(MyResultsVisitor())
        ResultWriter(result).write_results(RebotSettings(output=original_output_xml, log=None, report=None))
​
​
class MyResultsVisitor(ResultVisitor):
​
    def start_errors(self, errors):
        errors.messages = [message for message in errors.messages if message.level != 'WARN']
        pass

Then you attach that WarningRemover as a listener.

robot --listener <path-to>/WarningRemover.py test.robot

4 Likes

Thank you so much I followed it and it worked great