How to implement a java library in Robot Framework

拈花ヽ惹草 提交于 2019-12-18 18:37:54

问题


How can I create a library in Eclipse and then import it in Robot FrameWork?

I am searching a lot now and none of the guides out to help me out.


回答1:


You need to do the following:

  • Create your java library

  • Add it to the classpath when running robot framework jython edition

Creating your java library:

  • Define a new java class. At this point try not to use a constructor yet (although it is possible to support constructors with fields)

  • Define the ROBOT_LIBRARY_SCOPE static String variable in the class.

    public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";

  • Define public methods (not static) that will be used as the keywords

Adding your library to the class path

  • Compile your classes - ideally to a jar

  • Add the jar to the class path when running jython. The easiest way to do this is with the MVN Robot Framework plugin. Another option is to wrap the jybot run in a batch file and add CLASSPATH definition to it. There are other options as well (gradle or ant for example).

Using your library in your code

  • You need to import your library using the full package path

    import library org.robot.sample.keywords.MyLibrary

https://blog.codecentric.de/en/2012/06/robot-framework-tutorial-writing-keyword-libraries-in-java/

You can see the full example of how to add a jar when using ride in this article

https://blog.codecentric.de/en/2012/04/robot-framework-tutorial-a-complete-example/



来源:https://stackoverflow.com/questions/31538919/how-to-implement-a-java-library-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!