Common Resource file usage for multiple RF projects in eclipse

Hi All,

We are trying to have a common resource file and locator file.py which can be used across multiple RF projects in eclipse. So, we tried placing the resource file in a location outside the eclipse project’s directory and tried to use the same in a RF project.

After importing the resource file, it is showing us a warning that,

  • RED does not support importing resources located outside of workspace. Keywords from this resource will not be recognized. Try to use Quick Fix (Ctrl+1) to link folder into the project.
  • Path ‘C:/RobotCommon/CommonUpointKeywords.resource’ points to location outside your workspace
  • Path ‘C:/RobotCommon/CommonUpointKeywords.resource’ is absolute. It is preferred to use relative paths.

image
Not able to do the Quick Fix in order to link this to the project.

Is there any way to have the common resource file used with all the keywords being recognized in the Test Suite?

Thanks!

From the error it looks like you need to create a symbolic link to the external folder inside your working project. I think that should fix the error.(Note: I am not using eclipse so its more of a guess :slight_smile: )

Put shared resource files into separate git repository and add that new repository as git submodule or subtree (or any similar tooling that allows combining multiple git repos into single checkout).

We do migrate common resource files to a library in a separate python project with its own lifecycle.
Our pipeline deploy such libraries in to our own pypi storage on Sonatypr Nexus from where all our python environments can pull python dependencies.

Robot projects then only need to pull the common resource library from nexus.

The benefit of a library with an own lifecycle is that all your projects can rely on different versions of your common resource. If you copy a resource file in to every project, every project must be adapted in case of changes.

is this lib then installed via pip?
Did you manage to use the auto code completion feature with imported lib?
I need to set an absolute path eg Resource …/…/…/venv/lib64/python3.9/site-packages/KeywordLibrary/

in order to get this working.

Yes, all works.

Auto completion depends on your ide. If done right, your keyword should be imported like any other library:

*** settings ***
Library    Keyword library

If you must relative path, it either means your library is not in pythonpath (like installed to the wrong python env).

Or maybe your library module has a different name than the library class.

In your library it think the folder structure must be:

  • (folder) KeywordLibrary
    – (file) KeywordLibrary.py
    — (class) KeywordLibrary

If anything has a different name your reference to the library is somehow different (but not comprehensive for me).

Hi Noordsestern,
To be clear when you write “We do migrate common resource files to a library” you mean you write first the framework resources files in Robot Syntax (high level keywords) and then you convert the resources files into phyton files in phyton programming language?
Is there any way to do this work in an automatic way?
Of course with this you gain the advantage to handle the library as described.
My question is: if so you do write the code “twice”? Wouldn’t it better to write first in python? And what if robotframework resources is written by someone who does not know phyton programming language?

Thank you

Hi @MatteoB ,

Yes, you are right: we write the functionality twice. But we only implement keywords twice, if we have more than project for the keyword. Most keywords remain in robot.

It is a question of skill distribution in your team. If you have only few python developers at hand, you have to think about how not to move too much logic in to python, otherwise non-python testers lose traction.

If you have many python developers, of course you can start with python keywords directly.

So it depends what you find as most efficient in your individual setup.

Regards,
Markus