Java Robot Framework

How can I utilize Robot Framework and its libraries within a Java environment? Specifically, I aim to automate interactions with the Notepad application on Windows through a Maven project in Java. How can I accomplish this?

If using the standalone Robot Framework, leveraging the Windows library makes it straightforward. However, my concern lies in achieving the same functionality within a Java context.

That won’t be easy. With Jython not being around anymore, Robot Framework cannot natively integrate with Java.

The question is: why do you want to use / involve Java? What problem do you aim to solve with that approach?

Thanks robin for your prompt response.
I have a task and it needs to automate notepad from java code. Navigating the web i can’t find any helpful resources.

Is there any library to do the required task or what to do the way forward?

Thanks,
Tayyab

That task does not make sense to me.

If you need to interact with an application (Notepad) from Java, you should write Java code to do so. Robot Framework should not play a role in that.

If you want to automate interaction with Notepad, you could use Robot Framework for that. Or another framework, be in from the Java ecosystem or the C# ecosystem, or some propriety automation tool.

But trying to run Robot Framework from Java is adding a layer of complexity that adds no value.

2 Likes

Your problem description doesn’t make it clear what is the “core thing” you want to use RF for ? Is it just to automate the UI parts ? Are you intending to call RF from actual java code or just from maven itself ? Why “notepad” ? Wouldn’t it be easier to just construct file you want to edit without notepad ? It almost feels like you do not have good grasp of robot itself ?

If the issue is “i want to automate windows ui interactions from java code” then im pretty sure you java can call .net dll via java’s JNI interface and utilize FlaUI project… For example, Robot Framework itself does not have any builtin features that does ui interactions but there’s are libraries written in python (in most cases) that call other libraries (written in python or what ever language) that does the actual heavy lifting. Like FlaUI in this case… But as as @robinmackaij said, if you want to mix robot into this, you will end up with multiple layers of abstraction.

2 Likes

I want to achieve something like this :

Set up a Java/Maven project

public static void main(){

// Open notepad
rpaWindowsLibrary.runKeyword(“Open Application”, “notepad.exe”);

// Get element attribute
Map element = (Map) rpaWindowsLibrary.runKeyword(“Get Element”, “title=testing”, “class=CalcFrame”, “controlname=Edit”);
}

@mtayyab153 Like @robinmackaij and @rasjani said it doesn’t make sense to use Java with RF unless you have a specific reason to do so. If you must use Java I suggest to take a look at this example: How To Automate Desktops Apps Using WinAppDriver | LambdaTest

I thought so …

First off, a lot of libraries for robot framework require that robot itself is also running - eg you have to have testsuites with testcases and keywords from libraries can be only then executed. Not all, but a lot will do this… Thus, you can’t expect to pick a library for robot and expect it to work like that …

Second, a lot of robot framework libraries are only bindings to other libraries libraries. These libs could be implemented in various language besides Python itself - which again would cause more troubles integrating those into jvm (java) … Also, as said earlier, robot in this case would add Yet An Another Layer of Abstraction where things could break/misbehave.

Probably your easiest options is to use winappdriver/ appium … And if that doesnt fulfill your needs, you could look into utilizing any dotnet/java bridge software to make calls directly into something like FlaUI libraries or if that is not good enough and you still insist on using robot framework libraries as they are - you could setup a remote server, load all your robot libraries into it and make calls over http to call those keywords within that remote server…

But for now, appium / winappdriver is most likely your easiest option…

1 Like