Repository navigation
Description
Given the following files (one for a test case and two for resources):
$ cat cases/case.robot
*** Settings ***
Resource rc/SSHClient.robot
Resource rc/TelnetClient.robot
*** Test Cases ***
My Test Case
SSHClient.Log On
TelnetClient.Log On
SSHClient.Log Off
TelnetClient.Log Off
$ cat rc/SSHClient.robot
*** Variables ***
${SERVER_IP} 1.2.3.4
${SERVER_USER} guest
${SERVER_PASSWORD} guest
*** Settings ***
Library SSHLibrary
*** Keywords ***
Log On
Open Connection ${SERVER_IP}
Login ${SERVER_USER} ${SERVER_PASSWORD}
Log Off
Close Connection
$ cat rc/TelnetClient.robot
*** Variables ***
${SERVER_IP} 1.2.3.4
${SERVER_USER} guest
${SERVER_PASSWORD} guest
*** Settings ***
Library Telnet
*** Keywords ***
Log On
Open Connection ${SERVER_IP}
Login ${SERVER_USER} ${SERVER_PASSWORD}
... login_prompt=Username:
... password_prompt=Password:
Log Off
Close Connection
When running case.robot this kind of warning appears:
[ WARN ] Keyword 'Open Connection' found both from a custom test library 'SSHLibrary' and a standard library 'Telnet'. The custom keyword is used. To select explicitly, and to get rid of this warning, use either 'SSHLibrary.Open Connection' or 'Telnet.Open Connection'.
[ WARN ] Keyword 'Login' found both from a custom test library 'SSHLibrary' and a standard library 'Telnet'. The custom keyword is used. To select explicitly, and to get rid of this warning, use either 'SSHLibrary.Login' or 'Telnet.Login'.
My Test Case
which seems to force us to prefix keywords in the resource files with the library name, even when they have imported only one library (with no name collision in the resource-file scope).
Should not be the scope of keywords called in resource files determined locally to the resource file? (at least, when they can be resolved in the resource-file scope as when we have been explicitly imported the corresponding library)
P.S.: I know that it is intended that keywords can be resolved at runtime to allow dynamically decide the implementation (I do not remember where I read about that behaviour though). However, this seems to hamper Robot framework keywords reusability, forcing us to work around by prefixing keywords, renaming them (globally unique...!), or implementing these keywords in a .py file (to be imported via Library). Please, you can also consult this resource example in the official user guide for additional evidences on how misleading is the current non-local scope resolution.
Activity
[-]Scope of keywords called in resource files is globally reinterpreted when resource file is imported from another file[/-][+]Scope of keywords called in resource files is globally reinterpreted when resource file is imported[/+]pekkaklarck commentedon Apr 23, 2018
I agree resource files should only see keywords they import themselves, not keywords in other resource files or libraries imported in the test case file directly or indirectly. Unfortunately changing that is a big task and I cannot make promises when it would happen.
One possible workaround is using
Set Library Search Orderkeyword to tell which library to use by default. You still need to prefix kws from the other library, though.MrBIN89 commentedon May 30, 2019
From my point of view, it would be very nice to fix it. At least, for now, it isn't so clear where is from some keyword become available to use at suite file. Is it become from the specified resource file or from another resource file (which is used in the first resource)
Any progress or estimations for now?
phoenix9047 commentedon Nov 11, 2020
Hi! Joining this discussion, it'd be so appreciated to have this fixed in any future version! My code in one large project would be so much more fine and clear if there wouldn't be this limitation; and while it's there - I have to use a tricky workaround to avoid usage of these two libraries in the same project..
Thank you!
pekkaklarck commentedon Nov 14, 2022
This is related to #4366 that was fixed in RF 6.0. I hope we could get this fixed soon as well and assign this tentatively to RF 6.1 scope
pekkaklarck commentedon Jan 4, 2023
Unfortunately it turned out this isn't as easy to implement as #4366 was. When there are two library keywords that match the keyword that was used, we could easily find out which user keyword used the conflicting keyword. Unfortunately that
UserKeywordHandlerobject doesn't have a direct access to the resource file it belongs to. With some effort we could find theUserLibraryinstance that contains thatUserKeywordHandler, but thatUserLibraryonly contains keywords and doesn't know anything about imports. The actualResourceFileobject containing imports, keywords and variables isn't actually even preserved after it's processed.With some enhancements to the aforementioned model objects we could make the resource file and its imports accessible via the user keyword that caused the conflict. Unfortunately these imports would just be a list of strings and we needed to somehow map them to libraries that have been imported. That gets even more complicated than anything earlier.
A proper way to fix this is pretty much re-implementing keyword namespaces so that keywords in resources or libraries imported in different resource files don't leak like this in the first place. That's a pretty big task, and I was hoping we could resolve conflict otherwise until we get it done. Unfortunately it seems also resolving conflicts is lot of work as well, so it's probably best to wait until we can do the bigger rewrite.
pekkaklarck commentedon Aug 25, 2023
Unfortunate too big for RF 7.
jonsim commentedon Nov 4, 2025
Just adding another use-case to this - consider the following test and resource file:
test.resource
test.robot
Running
test.robotresults in the test unexpectedly using the Log File keyword defined in the test file, not the one imported into the resource file (similar to #2970 but for keywords). While this example is somewhat contrived, this is a real issue in practice whentest.resourceis third-party code. The conflict can also occur when integrating two libraries together (e.g. if the resource file imports OperatingSystem and your test file imports SSHLibrary, the resource file will use conflicting keywords from SSHLibrary).The only robust way to write resource files appears to be to prefix all keywords with the library or resource file name.
MarvKler commentedon Mar 24, 2026
Hi guys!
I have another use case:
Keyword Library Ais used byKeyword Library BandKeyword Library Bis used within a.robotsuite file. At the moment, you also can see, select & use the keywords fromKeyword Library Adirectly in the test case.In my case, sometimes i want to see keywords from
Keyword Library Aonly inKeyword Library B, but not in the.robotsuite file, because in the test case the testers should use only keywords fromKeyword Library B.PS: Keyword Library A/B=
.resourcefiles (not.py)@pekkaklarck is this use case getting resolved by this feature / bug fix ?
I hope this is the correct feature to ask - at least for me it sounds similiar to my use case.
[-]Scope of keywords called in resource files is globally reinterpreted when resource file is imported[/-][+]Resource files should only see keywords it imports itself directly or indirectly[/+]pekkaklarck commentedon Sep 12, 2026
We haven't started detailed RF 8 planning yet, but this is likely going to be one of the most important issues to fix in that release. My current thinking is that these are the desired semantics:
In practice a resource file should see keywords that are defined in the resource file itself or that it imports either directly or indirectly via other resource files.
pekkaklarck commentedon Sep 12, 2026
This change is backwards incompatible and we need to handle it gracefully. In practice if a keyword isn't found using the new semantics, we should search for it starting from the test case file level which basically matched the old semantics. Then we have two alternatives:
I believe the first approach is better, because then old tests ought to continue to work. This issue would probably still deserve the
backwards incompatiblelabel, because in some cases the keyword that is used could also change.