Calling robot keywords from java libraries

559 views
Skip to first unread message

cjp

unread,
Sep 21, 2017, 1:49:52 PM9/21/17
to robotframework-users
Is there a way to call keywords from Java code that is implementing a library... 

In python, I'd just do:

from robot.libraries.BuiltIn import BuiltIn
BuiltIn().run_keyword(...)

What would be the equivalent for library implemented in java?
 

Bassam Khouri

unread,
Sep 25, 2017, 2:17:28 PM9/25/17
to robotframework-users
I don't think it's possible since robot framework is written in python.  the reason why Java can be used with robot framework is due to Jython.  it supports Java class and jython.

Others can correct me if I said something incorrect.

Kevin O.

unread,
Sep 25, 2017, 5:57:25 PM9/25/17
to robotframework-users
It would look similar to this:


public static Selenium2Library getLibraryInstance() throws ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
engine.put("library", "Selenium2Library");
engine.eval("from robot.libraries.BuiltIn import BuiltIn");
engine.eval("instance = BuiltIn().get_library_instance(library)");
return (Selenium2Library) engine.get("instance");

Olivier Mireault

unread,
Sep 25, 2017, 6:39:09 PM9/25/17
to robotframework-users
Run a remote server. We use Sikuli (Java) with Robotframework. 

cjp

unread,
Sep 25, 2017, 6:55:18 PM9/25/17
to robotframe...@googlegroups.com


On Monday, September 25, 2017 at 6:39:09 PM UTC-4, Olivier Mireault wrote:
Run a remote server. We use Sikuli (Java) with Robotframework. 


I'm familiar with the remote server, but how does that help you call builtin (or other library) keywords from your java code. Also I'm fine w/ running the jython version of rf. 

The constraint is more that I need to stay in java (not jython/python) for all keyword implementation and that seems to be raising important limitations, and without having entry points in org.robotframework.Robotframework (java internal api) that match up the python robot.* internal apis, I'm not sure how to work around them.

Cyril Santune

unread,
Sep 30, 2021, 6:17:26 AM9/30/21
to robotframework-users
Hi,

I try to use the remote server with java, but the question is still opened, how can I call robotframework keywords from java ?

I try the SriptEngine describe above but it fails.

Is there any new way to do this ? Or a complete working example ?

Thanks,
Cyril
Reply all
Reply to author
Forward
0 new messages