简体   繁体   中英

Robotframework import own Python library

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.

给出如下绝对路径:

Library    /absolute/path/Library.py

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM