Accessing keywords of one .robot in another .robot file

1,842 views
Skip to first unread message

Gowri reddi

unread,
Apr 4, 2016, 1:52:44 AM4/4/16
to robotframework-users
Hi all,

            How to access keywords of one .robot in another .robot file?

Regards,
Gowri

J Wipf

unread,
Apr 4, 2016, 9:14:36 AM4/4/16
to robotframework-users
Include the file under settings.

For example if you want to include the keywords of second.robot in first.robot then the following settings in first.robot would enable this. 
*** Settings ***
Resource    second.robot

J Wipf

unread,
Apr 4, 2016, 9:15:17 AM4/4/16
to robotframework-users
(With proper paths to the objects)
Message has been deleted

Gowri reddi

unread,
Apr 5, 2016, 2:01:54 AM4/5/16
to robotframework-users
Actually my requirement is, If I take 2 .robot files under one folder and run then the test cases in both files are getting executed. But the test cases are getting repeated in all .robot files. So that I prefer to use common keyword which is created under that folder. So how can I access that common keyword in both of these .robot files?

Regards,
Gowri

On Tuesday, April 5, 2016 at 11:22:30 AM UTC+5:30, Gowri reddi wrote:
It is not working for me.

Gowri reddi

unread,
Apr 5, 2016, 2:03:18 AM4/5/16
to robotframework-users
This snapshot explains my question better
Capture.PNG

Andrea Bisello

unread,
Apr 5, 2016, 3:14:17 AM4/5/16
to robotframework-users
i simply put resource in another folder so for example my robot structure is

/project1/resource.robot
/project1/area1/test1.robot
/project1/area1/test2.robot
/project1/area1/test3.robot

in test1.robot test2.robot and test3.robot i put

Resource ../resource.robot

and then with robot area1 , robot will execute test1,2,3 and every test can access resource.robot

Gowri reddi

unread,
Apr 5, 2016, 5:51:07 AM4/5/16
to robotframework-users
Hi Andrea Bisello,


I tried as u said. But not able to access the keyword of resource.robot in test1.robot.
I am attaching my sample files. Could you please share a sample.

Thanks,
Gowri
resource.robot
test1.robot
test2.robot

Hélio Guilherme

unread,
Apr 5, 2016, 7:00:54 AM4/5/16
to robotframework-users
There are several errors in your files. Attached are the corrected files.

When you use paths with the Windows "\" you must escape them, becoming "\\".
But better is to use the variable ${/} that would be translated to the correct path separator.
Whenever is possible use relative paths (it was suggested to you to put the resource file in a higher folder/directory level with ../).
I modified test files to use the same folder/directory as the tests, which is ./ (you should use it if it not working as they are now).
The Resource files must not have Test cases, so I commented it.
You intended to call keyword1 and keyword2, but instead you Logged those words. Now they are called and found because I removed the Test case from Resource.

I see that you use RIDE, it will help you to write error free tests (It should have complaint about the faulty Resource file use!).
Also, always look for the output or logs, they should have the info you need.

Hélio
accessingkeywordsofone_robotinanother_robotfile.zip
Reply all
Reply to author
Forward
0 new messages