问题描述
我正在尝试在 RIDE 中使用 Java 库.我找到了一个很好的教程(https://blog.codecentric.de/en/2012/06/robot-framework-tutorial-writing-keyword-libraries-in-java/)我遵循它,但是当需要在 RIDE 中导入和使用 java 库(数据库库)时.它失败.当我查看具有不同导入的页面时,java 库是用红色编写的,而不是像其他库一样用黑色编写.
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.
当我尝试使用 Jybot 运行时,我收到一条众所周知的消息:[ 错误 ] 文件C:\Users\XXXXXX\Documents\Robot_Test\implementation\DB_Test\Example.html"中的错误:导入测试库org.robot.database.keywords.DatabaseLibrary"失败:ImportError:没有名为机器人的模块
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
我遵循教程的每一行,即使是设置了 CLASSPATH.
I follow every line of the tutorial, even the with the set CLASSPATH.
有什么想法吗?(我知道Python中存在这个库,但我想编写自己的java库^^)谢谢
Any idea ? ( I know that this library exist in Python, but I want to write my own java libraries ^^)Thanks
推荐答案
这对我有用:
- Jython 2.7b4
- 机器人框架 2.8.7
- 骑行 1.3
创建Lib并编译(不需要jar)
Create Lib and compile it (you do not need to jar it)
目录结构是
run_ride.sh
libs/DemoLib.class
tests/DemoLibTest.txt
摘自测试/DemoLibTest.txt:
Excerpt from tests/DemoLibTest.txt:
* Settings
Library ../libs/DemoLib.class
* Test Cases
DemoLibTest
Print Demo
Start Ride,切换到Run"选项卡,选择Execution Profile: jybot
,按Start,输出为:
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
在您的 Ride 启动脚本中,以确保您的库真正导入.顺便说一句,在我的 Ride 中,导入也标记为红色.有时重新启动 Ride 可能会有所帮助.但如果您的设置正确,颜色并不代表任何意义.
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.
这篇关于在 RIDE 中导入 Java 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!