3
votes

I'm trying to use a java library in RIDE. I found a good tutorial( https://blog.codecentric.de/en/2012/06/robot-framework-tutorial-writing-keyword-libraries-in-java/) I follow it, but when the time comes to import and use the java library ( Database Library)in RIDE. It fails. When I look the page with my different imports, the java library is written in red and not in black as the others.

And when I try to run with Jybot, I have the well-known message : [ ERROR ] Error in file 'C:\Users\XXXXXX\Documents\Robot_Test\implementation\DB_Test\Example.html': Importing test library 'org.robot.database.keywords.DatabaseLibrary' failed: ImportError: No module named robot

I follow every line of the tutorial, even the with the set CLASSPATH.

Any idea ? ( I know that this library exist in Python, but I want to write my own java libraries ^^) Thanks

1
It's hard to help without more information. Have you bundled your class up into a JAR file? Can you add the command(s) you use to generate the error? Include a dump of the CLASSPATH, too.Mark
Hi, Sorry for delay, finaly nobody where I'm making my internship use Robotframework, so they said that I may just stay using the ptyhon libraries. But still want to know how using java lib ^^. So yes, I bundled my class into a jar file. I don't use a command to execute test, I'm using RIDE, kind of Eclipse but for Robot framework, so I just push : Run test, and then received the error message. To set my classpath, found this : set classpath=.;%CLASSPATH%;myClass.jarTony

1 Answers

0
votes

This worked for me using:

  • Jython 2.7b4
  • Robotframework 2.8.7
  • Ride 1.3

Create Lib and compile it (you do not need to jar it)

Directory structure is

run_ride.sh
libs/DemoLib.class
tests/DemoLibTest.txt

Excerpt from tests/DemoLibTest.txt:

* Settings
Library           ../libs/DemoLib.class

* Test Cases
DemoLibTest
    Print Demo

Start Ride, switch to tab "Run", choose Execution Profile: jybot, press Start, output is:

Starting test: tests.DemoLibTest.DemoLibTest
20150304 19:13:20.321 :  INFO : ---------- Demo ---------------

To avoid confusion put this line

echo $CLASSPATH

in your Ride startup script in order to ensure that your library is really imported. By the way, in my Ride the import is also marked red. Sometimes restarting Ride might help. But the colour does not mean anything, if your settings are correct.