Wrong/invalid warrning on duplicate keyword

207 views
Skip to first unread message

Tatu Aalto

unread,
Oct 2, 2014, 3:05:20 AM10/2/14
to robotframe...@googlegroups.com
Ugh

When I run my long test, I get warning saying this:

20141002 09:29:22.029 WARN Keyword 'Select From List' found both from a user created test library 'Selenium2Library' and Robot Framework standard library 'Remote'. The user created keyword is used. To select explicitly, and to get rid of this warning, use either 'Selenium2Library.Select From List' or 'SwingLibrary.Select From List'.

Now when I grep my test data, I did not find keyword that would not have prefix Selenium2Library. or SwingLibrary. in front of the "Select From List" keyword. So did look at the output.xml around the time when warning was issued and in there I see:
<status status="PASS" endtime="20141002 09:29:22.027" starttime="20141002 09:29:21.999"></status>
</kw>
<kw type="kw" name="Selenium2Library.Select From List">
<doc>Selects `*items` from list identified by `locator`</doc>
<arguments>
<arg>${locator}</arg>
<arg>${data_type}</arg>
</arguments>
<msg timestamp="20141002 09:29:22.031" level="TRACE">Arguments: [ u'xpath=//select[@name="type"]' | u'Boolean' ]</msg>


So the log is also saying that the Selenium2Library. prefix is there, when the keyword is executed. Therefore this leaves me quite confused, why the warning was raised? I did also grep (grep -i "Select From List" output/output.xml | grep -iv Selenium2Library) the whole output.xml and did not find where the warning could be issued. Actually the only output of the grep was:
<arg>Select From List By Label</arg>
<msg timestamp="20141002 09:27:36.118" level="TRACE">Arguments: [ u'Select From List By Label' | u'${selector}' | u'${managed_role}' ]</msg>

But that is from different time and from different keyword. So I am more confused what is going on. The test executes the keywords successfully and test passes. So I have no idea where or why the warn message is issued. Does anyone have any pointers where to look next?

-Tatu


Bryan Oakley

unread,
Oct 2, 2014, 6:48:35 AM10/2/14
to Tatu Aalto, robotframework-users
Is that really the exact warning error? Did you copy and paste it, or type it in?  It looks a little confusing because it says it found the keyword in Selenium2Library and in Remote, but that it used the one from SwingLibrary.

What it means is that you have imported two of those libraries, and they each have the same keyword. It is saying that you are _not_ calling it like "Selenium2LIbrary.Select From List" but that you should. Because you are not calling it that way, it has to guess which keyword to use. Apparently it is guessing right since your tests work.

"Selenium2Library.Select From List" is showing up in the log file to let you know what it _did_, not necessarily what you told it to do.

Looking at the documentation, both SwingLibrary and Selenium2Library have a keyword named "Select from list". So, if you have a test case or resource file that imports both SwingLibrary and Selenium2Library, and that test case or resource file calls "Select From List", you will get the error you got, because robot doesn't know which library to use for that keyword.




--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Kevin O.

unread,
Oct 2, 2014, 5:19:40 PM10/2/14
to robotframe...@googlegroups.com
The timestamp on the warning message could be matched up to the timestamps of the tests in the test log or report files. But that might be too easy.
You could use a listener - this worked for me.

class MyListener:

    ROBOT_LISTENER_API_VERSION = 2
    
    def __init__(self):
        self._suite = 'UNKOWN'
        self._test = 'UNKOWN'

    def start_test(self, name, attributes):
        self._test = name

    def start_suite(self, name, attributes):
        self._suite = name
 
    def message(self, message):
        if message['level'] == 'WARN' and 'To select explicitly' in message['message']:
            print "duplicate keyword warning logged during execution of %s : %s" % (self._suite, self._test)

Pekka Klärck

unread,
Oct 2, 2014, 5:46:16 PM10/2/14
to Tatu Aalto, robotframework-users
2014-10-02 10:05 GMT+03:00 Tatu Aalto <aalto...@gmail.com>:
>
> Ugh
>
> When I run my long test, I get warning saying this:
>
> 20141002 09:29:22.029 WARN Keyword 'Select From List' found both from a user created test library 'Selenium2Library' and Robot Framework standard library 'Remote'. The user created keyword is used. To select explicitly, and to get rid of this warning, use either 'Selenium2Library.Select From List' or 'SwingLibrary.Select From List'.

Bryan already commented about this, but could you verify that the
error really first said the keyword was found from Se2Lib and Remote,
and then later that it actually was in Se2Lib and SwingLibrary? That
looks pretty strange. Are you using normal SwingLibrary or
RemoteSwingLibrary?

> So the log is also saying that the Selenium2Library. prefix is there, when the keyword is executed.

That doesn't tell much. Log always shows the library name prefix even
if you wouldn't have used it in the test data.

Is it so that the warning is not linked to the executed keyword in
this case? Warnings logged by keywords themselves are linked, and if
that's not the case here I could take a look could such linking be
added. Until that you can try Kevin's listener to see can you find the
offending keyword.

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

Tatu Aalto

unread,
Oct 4, 2014, 4:49:26 AM10/4/14
to Pekka Klärck, robotframework-users
Ugh

Sorry for delayed answer, had a flu.

[1] https://github.com/ombre42/jrobotremoteserver
On 3.10.2014 0:46, Pekka Klärck wrote:
> 2014-10-02 10:05 GMT+03:00 Tatu Aalto <aalto...@gmail.com>:
>> Ugh
>>
>> When I run my long test, I get warning saying this:
>>
>> 20141002 09:29:22.029 WARN Keyword 'Select From List' found both from a user created test library 'Selenium2Library' and Robot Framework standard library 'Remote'. The user created keyword is used. To select explicitly, and to get rid of this warning, use either 'Selenium2Library.Select From List' or 'SwingLibrary.Select From List'.
> Bryan already commented about this, but could you verify that the
> error really first said the keyword was found from Se2Lib and Remote,
> and then later that it actually was in Se2Lib and SwingLibrary? That
> looks pretty strange. Are you using normal SwingLibrary or
> RemoteSwingLibrary?
Yes, I am sure, that was pure copy/paste from the log.html. I have
assumed that it caused by the fact that I run my test with pybot and use
SwingLibrary over the Java remote server [1] .
>> So the log is also saying that the Selenium2Library. prefix is there, when the keyword is executed.
> That doesn't tell much. Log always shows the library name prefix even
> if you wouldn't have used it in the test data.
Ah, did not know that.
> Is it so that the warning is not linked to the executed keyword in
> this case? Warnings logged by keywords themselves are linked, and if
> that's not the case here I could take a look could such linking be
> added. Until that you can try Kevin's listener to see can you find the
> offending keyword.
Yes, that is correct. It only displays a warning (on the top of the
log.html), with the text, but warning is not a link (like it usually is)
to jump directly to the keyword that caused the warning.

Because so much wonder did come of this question, I did create an
example, that is same as my setup. The attachment contains an example
how the warn message can be generated, example requires that
SwingLibrary and Java Remote server jars (not included in the zip file)
are in same folder where you extracted the zip file. If you do not want
to run the demo there is also log.html.

So is this a bug or not?
> Cheers,
> .peke

tmp.zip

Pekka Klärck

unread,
Oct 5, 2014, 4:43:19 PM10/5/14
to Tatu Aalto, robotframework-users
2014-10-04 11:49 GMT+03:00 Tatu Aalto <aalto...@gmail.com>:
>>
>> Bryan already commented about this, but could you verify that the
>> error really first said the keyword was found from Se2Lib and Remote,
>> and then later that it actually was in Se2Lib and SwingLibrary? That
>> looks pretty strange. Are you using normal SwingLibrary or
>> RemoteSwingLibrary?
>
> Yes, I am sure, that was pure copy/paste from the log.html. I have assumed
> that it caused by the fact that I run my test with pybot and use
> SwingLibrary over the Java remote server [1] .

I looked at the example you proivded and realized that the reason for
the inconsistent error message was that you used WITH NAME syntax to
give a custom name to SwingLibrary you imported via Remote. Looking at
the code it is clear that the error message always shows the real
library name (Remote in your case) but keyword names use the given
alias (SwingLibrary in your case). I'll change the error so that it
will be clearer when using WITH NAME syntax.

>> Is it so that the warning is not linked to the executed keyword in
>> this case? Warnings logged by keywords themselves are linked, and if
>> that's not the case here I could take a look could such linking be
>> added. Until that you can try Kevin's listener to see can you find the
>> offending keyword.
>
> Yes, that is correct. It only displays a warning (on the top of the
> log.html), with the text, but warning is not a link (like it usually is) to
> jump directly to the keyword that caused the warning.

The reason for this bug is that the warning is logged already before
the keyword is actually executed, and the is nothing where the warning
could be linked to. I already implemented a simple solution to delay
logging the warning until the keyword is running, and that makes the
warning a link. In the current form this solution could have a small
performance or memory penalty because it affects every executed
keyword, but I already have an idea how to avoid it.

> So is this a bug or not?

There are actually several bugs:

1) The error message is inconsistent. This was already discussed above
and I'll fix it.

2) The warning doesn't link to the place where it occurred. Also this
was discussed above and I'll fix it too.

3) Remote should not be considered a standard library when deciding
does finding keyword found from two libraries cause a failure or just
a warning. The main motivation for this functionality is that it
avoids failures if we add a new standard library keyword that happens
to have same name as a custom library you use. Because Remote is a
proxy we don't know what keywords it provides and if is effectively a
custom library.

Notice that fixing 3) will make you test fail. Because it is a
backwards incompatible change, I'm not sure should we fix it already
in RF 2.8.6 or wait until 2.9. The failure would pinpoint where the
error is so fixing it would be easy, but in general we try to avoid
changes that can break tests in minor releases.

Tatu Aalto

unread,
Oct 6, 2014, 4:17:28 AM10/6/14
to Pekka Klärck, robotframework-users

Ugh

At least I have learned to write custom (and some of the standard libraries) with the libraryName.keywordName syntax, because there always is namespace collisions. So from my point of view fixing the point 3 in 2.8.6 is OK. Of course some others may not feel it like that and doing backwards incompatible change in minor release is not always recommended.

-Tatu
Send from my mobile

Pekka Klärck

unread,
Oct 6, 2014, 2:56:39 PM10/6/14
to Tatu Aalto, robotframework-users
2014-10-05 23:43 GMT+03:00 Pekka Klärck <pe...@iki.fi>:
> 2014-10-04 11:49 GMT+03:00 Tatu Aalto <aalto...@gmail.com>:
>> So is this a bug or not?
>
> There are actually several bugs:
>
> 1) The error message is inconsistent. This was already discussed above
> and I'll fix it.

Fixed: https://github.com/robotframework/robotframework/issues/1814

> 2) The warning doesn't link to the place where it occurred. Also this
> was discussed above and I'll fix it too.

Fixed: https://github.com/robotframework/robotframework/issues/1813

> 3) Remote should not be considered a standard library when deciding
> does finding keyword found from two libraries cause a failure or just
> a warning. The main motivation for this functionality is that it
> avoids failures if we add a new standard library keyword that happens
> to have same name as a custom library you use. Because Remote is a
> proxy we don't know what keywords it provides and if is effectively a
> custom library.
>
> Notice that fixing 3) will make you test fail. Because it is a
> backwards incompatible change, I'm not sure should we fix it already
> in RF 2.8.6 or wait until 2.9. The failure would pinpoint where the
> error is so fixing it would be easy, but in general we try to avoid
> changes that can break tests in minor releases.

Decided to postpone until RF 2.9:
https://github.com/robotframework/robotframework/issues/1815
Reply all
Reply to author
Forward
0 new messages