Apologies if I asked this before: "RemoveKeywords not working".

724 views
Skip to first unread message

Skip Huffman

unread,
Jan 2, 2014, 9:01:14 AM1/2/14
to robotframework-users
I thought I asked this question already, but I cannot find the answer, and my question is still open on stack overflow  http://stackoverflow.com/questions/20008953/how-can-i-tell-robot-framework-not-to-log-a-keyword

I would like for my logs to NOT include the "Set Variable", "Set Test Variable" etc items as they are redundant with my test names and could confuse readers of the report.  RemoveKeywords does not seem to remove this keyword, so I must be using it wrong.  Could someone include an example where the Robot Framework code sets a variables to a constant but when run with pybot.... the resulting logs will not include those keywords.

Thank you,

Skip Huffmaan


--
Skip Huffman
Senior Software Engineer in Test/Continuous Integration

Pekka Klärck

unread,
Jan 3, 2014, 7:42:26 PM1/3/14
to Skip Huffman, robotframework-users
2014/1/2 Skip Huffman <skiph...@gmail.com>:
> I thought I asked this question already, but I cannot find the answer, and
> my question is still open on stack overflow
> http://stackoverflow.com/questions/20008953/how-can-i-tell-robot-framework-not-to-log-a-keyword
>
> I would like for my logs to NOT include the "Set Variable", "Set Test
> Variable" etc items as they are redundant with my test names and could
> confuse readers of the report. RemoveKeywords does not seem to remove this
> keyword, so I must be using it wrong. Could someone include an example
> where the Robot Framework code sets a variables to a constant but when run
> with pybot.... the resulting logs will not include those keywords.

Answered your question on SO:

The problem is that when you assign a variable like `${var} =
Keyword`, the name of the keyword in Robot Framework outputs is
`${var} = Keyword`, not `Keyword` as you would expect. If your keyword
is from a library or a resource file, its name will also be included
like `${var} = MyLibrary.Keyword`. The latter is a feature but the
former is a bug [1] that is hopefully fixed in RF 2.9.

An easy workaround for the keyword name, for now, including the
variable name is using wildcards. Something like this ought to work
for you:

--RemoveKeywords 'name:* = BuiltIn.Set Variable'

[1] http://code.google.com/p/robotframework/issues/detail?id=1611

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Kevin O.

unread,
Jan 6, 2014, 11:19:33 AM1/6/14
to robotframe...@googlegroups.com, Skip Huffman
Skip,
--removekeywords does exactly what it says it does in the user guide, removes the data beneath the keywords your are matching with the NAME: option.
You want functionality that is not provided - deleting the matched keywords and any data associated with them.
I would either:
  • put in an enhancement request and wait for this functionality
  • move the setting of variables to a user keyword in the test suite. If your user keywords have descriptive names, then no one should feel the need to drill down into them and see the Set Variable keywords

NAME:<pattern>
Remove data from all keywords matching the given pattern regardless the keyword status. The pattern is matched against the full name of the keyword, prefixed with the possible library or resource file name. The pattern is case, space, and underscore insensitive, and it may contain * and ? as wildcards.

Pekka Klärck

unread,
Jan 6, 2014, 2:07:19 PM1/6/14
to ombre42 ., robotframework-users, Skip Huffman
2014/1/6 Kevin O. <korm...@gmail.com>:
> Skip,
> --removekeywords does exactly what it says it does in the user guide,
> removes the data beneath the keywords your are matching with the NAME:
> option.
> You want functionality that is not provided - deleting the matched keywords
> and any data associated with them.

This is a good point. `--RemoveKeywords NAME:xxx` doesn't remove the
keyword itself, just date it contains. The main reason is that this
command line option is there mainly to make outputs smaller. The
keyword itself is left there to make it easier to understand what has
happened.

> I would either:
>
> - put in an enhancement request and wait for this functionality
> - move the setting of variables to a user keyword in the test suite. If your
> user keywords have descriptive names, then no one should feel the need to
> drill down into them and see the Set Variable keywords

A third option is creating a script that removes these keywords from
outputs and using Rebot to generate logs afterwards. This would be
rather easy using the exposed result API [1] but such post-processing
obviously adds an extra step to your test execution.

[1] https://robot-framework.readthedocs.org/en/2.8.3/autodoc/robot.result.html

gpe atmpro

unread,
Aug 3, 2016, 4:00:17 AM8/3/16
to robotframework-users, korm...@gmail.com, skiph...@gmail.com
First of all thanks for everything :)

--RemoveKeywords works perfectly for the log.html. That already helps a lot on the memory side, but as written in the doc, this filtering only happens on parsing the output.xml. It leaves this xml with all the useless keywords. Is it there a way to get it out of the xml all together. Something like a annotation [NOOUTPUT] on the keyword would be very convenient.

Having so much output from a for loop, our xml is big on memory. Writing these megabytes of data certainly also slows down the whole testing process, which is unfortunate useless data.

Pekka Klärck

unread,
Aug 4, 2016, 7:43:16 AM8/4/16
to gpe....@gmail.com, robotframework-users
2016-08-03 10:59 GMT+03:00 gpe atmpro <gpe....@gmail.com>:
> First of all thanks for everything :)

You are welcome. =)

> --RemoveKeywords works perfectly for the log.html. That already helps a lot
> on the memory side, but as written in the doc, this filtering only happens
> on parsing the output.xml. It leaves this xml with all the useless keywords.
> Is it there a way to get it out of the xml all together. Something like a
> annotation [NOOUTPUT] on the keyword would be very convenient.

Unfortunately it isn't possible to remove information from output.xml
during test execution. You can, however, do that after execution using
the same option with Rebot and specifying a new output file:

rebot --removekeywords <pattern> --output new.xml original.xml

If you want to reduce the overall time for running tests and
processing results, you can disable log and report generation when
running tests using `--log NONE --report NONE`.

Depending on your needs, you may also want to consider using
--FlattenKeywords. It drops unnecessary elements already when
output.xml is parsed and thus makes the overall processing faster.

> Having so much output from a for loop, our xml is big on memory. Writing
> these megabytes of data certainly also slows down the whole testing process,
> which is unfortunate useless data.

Sure. The best way to avoid unnecessary data and to control exactly
what is logged, is moving the logic from the for loop in Robot data to
a test library.

gpe atmpro

unread,
Aug 8, 2016, 2:43:57 AM8/8/16
to Pekka Klärck, robotframework-users
Thanks, I already figured out these points thanks to the very thorough documentation.

I guess moving this loop makes a lot of sense actually.

Have a great day
--

Best regards,

 

G.Pe.

 


m:pro IT Consult GmbH
Kirchgasse 47, 65183 Wiesbaden, Germany
fon: +49 611 3984 30  fax: +49 611 3984 312
www.mpro.de

Geschäftsführer: Jens H. Schroeder
AG Wiesbaden HRB 9589

Reply all
Reply to author
Forward
0 new messages