Loading libraries to global scope

When there are multiple suites within robot execution and certain libraries are loaded multiple times, in some scenarios, single library can be in state that is not expected. I think this is because when library is loaded as GLOBAL, it gets loaded and instantiated once but it wont be replaced be following Library imports …

Would it be possible or make sense to have some sort of cache table of what parameters where used import the library and if they differ, already existing library would be replaced.

Yeah, this is about plugin parameter to SeleniumLibrary but i think the actual issue is within rf core itself, not in SL but maybe @aaltat can chime in ?

Yes, it’s pretty annoying to debug. There are sever RF issues that might be related in this post https://github.com/robotframework/robotframework/issues/3417#issuecomment-625726261

The problem currently is that, by looking test data, it’s impossible to know what import is actually active during run time. And currently I de not good way to debug it. The best option that I have, is to import library only one time in some global resource file and import that resource file where it is needed.

Could shared libraries like in pabot be an opportunity? Load every lib once and share it everywhere?

Markus, i have not used pabot nor I haven’t checked how rf does importing and does its scope handling but I guess that would not help as, it looks like that is the exact reason why this happens.

Let’s take SeleniumLibrary which has plugin mechanism which can be used to add new keywords to its own scope. Now, as even @aaltat said and suggested, when one has multiple Library calls in various resource/testdata files and some of them loads SeleniumLibrary and does not include the parameters to load the plugin (eg, code that would add new keywords) - in some cases this will lead to situation where the keywords from the plugin will are not available at runtime.

Here’s a somewhat related bug report for me: https://github.com/rasjani/robotframework-seleniumtestability/issues/54

In his report, he was using get_library_instance() within his own python libs and by the looks of it – that overwrote the existing SeleniumLibrary and because his previous instantiation was not using default parameters and get_library_instance() triggered a new instance, his next testcase case failed …

So, without actually verifying the behaviour, would that mean that get_library_instance() will always return a new instance and not already existing one ? Parameters play a role here ? It feels like a bug or oversight that one can overwrite the existing seleniumlibrary (or any global library like that)…

Bug ?