Overriding robot resource keywords

635 views
Skip to first unread message

Andrew Palmer

unread,
Dec 8, 2015, 2:41:19 PM12/8/15
to robotframework-users
Hi Robot Users,

Have a question on something I haven't been able to resolve. The setup I have, is a directory called resource/, which holds all the robot keywords I am using. I'm finding out, as I add new products to test however, that many are common and can use the same keywords, but some are not. So what I would like to do is have the ability to have a common resource directory, and then say a directory for each product which contain specific keywords for that product.

Example:

resource/
    common/
        common_resource.robot
        network.robot
        other_resource.robot
    product1/
        network.robot
    product2/
        some_resource.robot

Now let's say that common and product1 files network.robot both have a keyword that is called 'Get Network Info'. On most products, I'm expecting this keyword to work without changes, however, product1 is vastly different.

So my question is, let's say I import my resource files based on product name, that is, product1, product2, etc.. but regardless of the product, I still import common. What I would like to do is somehow take any keywords from product one and override any duplicates in common, so that IF there is a duplicate, I know that I need to use it from product1, not common.

The reasoning behind this is to avoid lengthy conditionals in resource keywords, (i.e. if product 1 do this, elif product2 do this, elif product3 do this... and so on).

Hopefully this makes sense, and hoping that some of you may have some suggestions on how to approach this. I can easily overwrite the common file to just remove the duplicated keyword from other product, but I'm guessing there is a better way.

Thanks all in advance!
Andy

Kevin O.

unread,
Dec 9, 2015, 11:20:58 AM12/9/15
to robotframework-users

Andrew Palmer

unread,
Dec 9, 2015, 12:25:36 PM12/9/15
to robotframework-users
Thanks Kevin,

This seems like a good option, will give this a shot.

Andy
Reply all
Reply to author
Forward
0 new messages