0
votes

I want to create and import a java custom library into RIDE.

Create the Java file based on the below link
(source for creation of test library : http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-libraries)

Here below is the java Library Code:

public class MyLibrary{

    public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
    public static final String ROBOT_LIBRARY_VERSION = "1.0";
    public static final String ROBOT_LIBRARY_DOC_FORMAT = "HTML";

    private int counter = 0;

    public void count() {
        counter += 1;
        System.out.println(counter);
    }

    public void clearCounter() {
        counter = 0;
    }    
}

Created the JAR file and placed in the path D:\Python27\Lib\site-packages

Installed the Jython and set the environment vairables, JYTHON_HOME=D:\jython2.7.0; JYTHONPATH = D:\jython2.7.0\bin

Open RIDE and attached the library with the keyword Library MyLibrary

It displayed the text in red. (Meaning it is not a recognized library).

2
The path D:\Python27\Lib\site-packages seams to be the CPython installation path, not Jython? Why do you put a JAR in it? - Laurent LAPORTE
Have you tried running your test from the command line? Maybe it's valid and RIDE just isn't seeing it. In other words, maybe this is a bug in RIDE and can be safely ignored. - Bryan Oakley
Hi Bryan, Thanks for your reply, Yes, i have tried to run from command line, same issue came. - Sarada Akurathi
Hi Laurent LAPORTE, Thanks for your reply, I have read some where that we have to place our custom libraries in that path, that's why i have copied to that path - Sarada Akurathi
still an issue? - Waman

2 Answers

1
votes

I tried compiling the java into class file and placing it under "~\jython2.7rc1\Lib\site-packages\MyLibrary.class"

When I run the below test it worked perfectly for me:

*** Settings ***
Library     MyLibrary

*** Test Cases ***
sample
   count 

Just in case you face issues with path of jython or Jybot, place jybot.bat in the path "C:\Python27\Scripts" folder and change the jybot.bat content to absolute value i.e

@echo off 
C:\jython2.7.0\bin\jython "C:\Python27\Lib\site-packages\robot\run.py" %*

This will resolve the path issues if any!

0
votes

You must add your library to CLASSPATH before running RIDE. For example:

set CLASSPATH=%CLASSPATH%;D:\Python27\Lib\site-packages\MyLibrary.jar
ride.py