1

I want to create a Python library and then import it to robotframework. My Python library structure is:

autotestlibrary
|_ testkeywordlibrary
  |_ logintest.py
  |_ homepagetest.py
|_ testobject
  |_ loginpage.py
  |_ homepage.py

I have created init file into each folder. But when I import autotestlibray into robotframework it can't find my library.

7
  • Is autotestlibrary directory in one of the directories specified in PYTHONPATH environment variable? Commented Oct 10, 2016 at 1:02
  • yes, autotestlibrary is under folder c:\workspace, i add path c:\worksapce in PYTHONPATH Commented Oct 10, 2016 at 2:57
  • Interesting. What is the exception you get when you import autotestlibrary? Commented Oct 10, 2016 at 5:45
  • in RIDE it can't find this library Commented Oct 10, 2016 at 14:36
  • I think @zvone ment for you to run Python interactively and try the import. You would probably get similar errors from Tools>RIDE Log output. (the Library will fail to import and show in red color if there are Python errors in it) Commented Oct 11, 2016 at 22:25

3 Answers 3

1

Give the absolute path like:

Library    /absolute/path/Library.py
Sign up to request clarification or add additional context in comments.

Comments

1

If autotestlibrary is in PYTHONPATH environment variable then use

Library    autotestlibrary.xyz

where xyz can be:

  • logintest.py
  • homepagetest.py
  • loginpage.py
  • homepage.py

I suggest you to always import the child most library, all the parent libraries will be imported automatically.

Comments

0

If your library is a class then the filename needs to be exactly as the class name.

So if you have a class inside of logintest.py which is called Logintest then your file needs to be renamed to Logintest.py

Read more here: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#importing-libraries

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.