Looking for Robot Framework examples with Java

3,557 views
Skip to first unread message

Mark Levison

unread,
Jan 26, 2011, 12:02:26 PM1/26/11
to robotframework-users Robotframework-Users
I'm working with a client who're building an ASP .NET application (MVC) and they're doing alot of the right things including using RobotFramework with Selenium to make through the browser testing less painful :-) For testing underneath the browser we had just assumed that it would be simple to make to write a simple bridge, however after some questions today I'm confused. Rather than detail my confusion I was hoping to look at some examples that show how Robot calls out to Java and then figure out what we need to do on the .NET side. However as I google I can't find an examples, even Andreas's blog was empty :-)

Where do I look?

Cheers
Mark Levison

MarkMark Levison | Agile Pain Relief Consulting | Certified Scrum Trainer
Agile Editor @ InfoQ | Blog | Twitter | Office: (613) 862-2538
Recent Entries:
Story Slicing How Small is Small Enough, Why use an Agile Coach

Markus Gaertner

unread,
Jan 26, 2011, 12:12:56 PM1/26/11
to ma...@mlevison.com, robotframework-users Robotframework-Users
Hi Mark, i

f you read my blog entry and Pekkas comments from September last year, are there any other open points?


Best
Dipl.-Inform. Markus Gärtner
http://www.shino.de/blog
http://www.it-agile.de
Twitter: @mgaertne



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

Pekka Klärck

unread,
Jan 29, 2011, 6:25:10 AM1/29/11
to ma...@mlevison.com, robotframework-users Robotframework-Users
2011/1/26 Mark Levison <ma...@mlevison.com>

>
> I'm working with a client who're building an ASP .NET application (MVC) and they're doing alot
> of the right things including using RobotFramework with Selenium to make through the browser
> testing less painful :-)

Nice!

> For testing underneath the browser we had just assumed that it would be simple to make to write
> a simple bridge, however after some questions today I'm confused. Rather than detail my
> confusion I was hoping to look at some examples that show how Robot calls out to Java and then
> figure out what we need to do on the .NET side. However as I google I can't find an examples,
> even Andreas's blog was empty :-)
> Where do I look?

Simple executable examples demonstrating Robot's features are
something we sorely miss. The test library API is, however, pretty
well documented in the User Guide [1]. A direct link to the latest
version of the test library section is [2]. As you can see, a library
can be created with Java as simply like this:

public class MyLibrary {
public void hello(String name) {
System.out.println("Hello, " + name + "!");
}
}

The above example creates a test library `MyLibrary` with keyword
`hello`. This kind of "static" libraries are very good for simple
cases. If the library gets larger, then it might be better to start
using JavaLibCore [3] which uses Robot's dynamic test library API
internally.

[1] http://code.google.com/p/robotframework/wiki/UserGuide
[2] http://robotframework.googlecode.com/svn/tags/robotframework-2.5.5/doc/userguide/RobotFrameworkUserGuide.html#creating-test-libraries
[3] http://code.google.com/p/robotframework-javatools/wiki/JavalibCore

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

semperos

unread,
Feb 8, 2011, 6:27:12 PM2/8/11
to robotframe...@googlegroups.com, ma...@mlevison.com
Could someone please provide a straight-forward example of calling an example test library written in Java with the standalone RobotFramework jar?

If I have a library "com.example.Foobar", here's what I have so far:

In my test script, add this line to add the library:
Library com.example.Foobar WITH NAME Foobar

At the command line, I know I need to add the jar containing my Foobar class to the classpath, but I'm not sure what other options are necessary. If someone could "sum it up", that would be great; the bits of documentation I've found in the user guide and in blog posts haven't come together to form a solution.

Markus Gaertner

unread,
Feb 8, 2011, 6:56:24 PM2/8/11
to daniel.l...@gmail.com, robotframe...@googlegroups.com, ma...@mlevison.com
Hi Daniel,

I don't get your problem. Could you please extend your description a
bit for me to get a clue about that? Thanks.

Best
Dipl.-Inform. Markus Gärtner
http://www.shino.de/blog
http://www.it-agile.de
Twitter: @mgaertne

nast...@gmail.com

unread,
Feb 8, 2011, 7:30:23 PM2/8/11
to semperos, robotframe...@googlegroups.com, ma...@mlevison.com
Run with jybot, should be no extra options neccesarry.

Nick

semperos

unread,
Feb 9, 2011, 10:07:02 AM2/9/11
to robotframe...@googlegroups.com, semperos, ma...@mlevison.com
@Nick - I need to use the standalone jar for distribution purposes, but thanks for the tip.

I'll try to rephrase my question. For example, if I wanted to run a test suite that only used built-in keywords, I could run the standalone jar as simply as this:

java -jar robotframework-2.5.6.jar my_simple_test_suite.txt

Now let's say I want to use the SwingLibrary (a Java library). I know that I need a "Library  SwingLibrary" in my actual test suite, but my questions is this: how do I run my test suite with the standalone RobotFramework jar from the command-line?

I know that the SwingLibrary jar has to be on my classpath, but I've seen examples with lots of other command-line options including pythonpath, etc. I'd like to see a simple example like the following:

java -cp robotframework-2.5.6;<path to SwingLibrary jar> <other necessary options> org.robotframework.RobotFramework my_test_suite.txt

But obviously with the necessary parts filled in. Can anyone provide this or point to a place where all of this is explained? I've found bits and pieces of the answer, but nothing that's added up to a successful run with the standalone RobotFramework jar while using a Java test library.

Thanks.

Janne Härkönen

unread,
Feb 9, 2011, 10:37:59 AM2/9/11
to daniel.l...@gmail.com, robotframe...@googlegroups.com, ma...@mlevison.com
Hi Daniel,

The JavaIntegration Wiki page[1] might be of interest to you. In
short, the easiest way is to use the org.robotframework.RobotFramework
class directly like this:

java -cp Foobar.jar:robotframework-2.5.3.jar
org.robotframework.RobotFramework example.html

[1] http://code.google.com/p/robotframework/wiki/JavaIntegration#Using_additional_Java_libraries

hth,
--J

--
Janne Härkönen | http://reaktor.fi
http://twitter.com/#!/janneharkonen

Laurent Carbonnaux

unread,
Feb 9, 2011, 11:06:54 AM2/9/11
to janne.t....@gmail.com, daniel.l...@gmail.com, robotframe...@googlegroups.com, ma...@mlevison.com
You may use also with XBootclasspath like this:

java -Xbootclasspath/a:lib/swinglibrary-0.14.jar:lib/registration-0.1.jar -jar robotframework-2.5.3.jar 

regards,
Laurent

2011/2/9 Janne Härkönen <janne.t....@gmail.com>

semperos

unread,
Feb 9, 2011, 3:04:05 PM2/9/11
to robotframe...@googlegroups.com, janne.t....@gmail.com, daniel.l...@gmail.com, ma...@mlevison.com
@Janne and Laurent, Thank you very much.

I think I grew confused over time by seeing folks integrate various test libraries in both Python and Java using different methods like the standalone jar and jybot. Needed a "this is how you do it," which of course the User Guide gives and I simply forgot about over time.

Thanks for your help. I'll be re-reading the user guide more closely.

Laurent Carbonnaux

unread,
Feb 10, 2011, 1:53:08 AM2/10/11
to daniel.l...@gmail.com, robotframe...@googlegroups.com, janne.t....@gmail.com, ma...@mlevison.com
Hi Daniel,

The difference between using jybot or standealone jar is that with standealone jar you don't need to install Python and Jython.
It helps for example when you want to run your test suites under hudson, Nothing more to do than adding a job using robotant to launch the standalone jar.

Enjoy rf!
Laurent.

2011/2/9 semperos <daniel.l...@gmail.com>
@Janne and Laurent, Thank you very much.

I think I grew confused over time by seeing folks integrate various test libraries in both Python and Java using different methods like the standalone jar and jybot. Needed a "this is how you do it," which of course the User Guide gives and I simply forgot about over time.

Thanks for your help. I'll be re-reading the user guide more closely.

--

AndreasEK

unread,
Feb 10, 2011, 5:23:50 AM2/10/11
to robotframework-users
Hi,

I am wondering if it would work, if we added something like this to
the manifest:

Class-Path: userlibs/*.jar

Since Java 6 you can use wildcards in classpaths, but I have never
tried it in the manifest.

Andreas

On Feb 9, 4:37 pm, Janne Härkönen <janne.t.harko...@gmail.com> wrote:
> Hi Daniel,
>
> On Wed, Feb 9, 2011 at 1:27 AM, semperos <daniel.l.grego...@gmail.com> wrote:
> > Could someone please provide a straight-forward example of calling an
> > example test library written in Java with the standalone RobotFramework jar?
>
> > If I have a library "com.example.Foobar", here's what I have so far:
>
> > In my test script, add this line to add the library:
> > Library com.example.Foobar WITH NAME Foobar
>
> > At the command line, I know I need to add the jar containing my Foobar class
> > to the classpath, but I'm not sure what other options are necessary. If
> > someone could "sum it up", that would be great; the bits of documentation
> > I've found in the user guide and in blog posts haven't come together to form
> > a solution.
>
> The JavaIntegration Wiki page[1] might be of interest to you. In
> short, the easiest way is to use the org.robotframework.RobotFramework
> class directly like this:
>
> java -cp Foobar.jar:robotframework-2.5.3.jar
> org.robotframework.RobotFramework example.html
>
> [1]http://code.google.com/p/robotframework/wiki/JavaIntegration#Using_ad...
Reply all
Reply to author
Forward
0 new messages