I haven't used RF with Selenium, but I am using it to test an HTTP based API so hopefully you can use this example and apply it to your situation.
There are a few parts to this. The first is that you need to build your Java class, and have it included on the classpath, followed by using it in your script. I had a gotcha here because for some reason RF didn't like reading Java code unless it is in a JAR file. I'm not sture why, maybe it's a Jython issue. I used a wrapper Gradle script to handle dependencies/build of my Java library (since I also have a few compile time deps), that generates a very basic shell script to run the tests.
src/main/java/com/mypackage/Foo.java
package com.mypackage;
public class Foo {
public void methodNameIsKeyword() {
// ...
}
}
build.gradle
apply plugin: "java"
repositories {
mavenCentral()
}
dependencies {
runtime "org.robotframework:robotframework:2.8.5"
}
task writeScript() {
def classpath = sourceSets.main.runtimeClasspath + files("build/libs/mylibrary.jar")
println "java -cp ${classpath.asPath} org.robotframework.RobotFramework \$@"
}
task wrapper(type: Wrapper) {
gradleVersion = "1.10"
}
The next step is to use your new keyword in your script
*** Settings ***
Library com.mypackage.Foo # constructor args go here.
*** Testcases ***
It should use the Java class
Method Name Is Keyword
Of course you class can take Constructor args, and have parameters/return values from your methods.