small medium large xlarge

07 Jan 2014, 07:11
Kim Faint (2 posts)


I am currently working on the example in Section 2.3, Swing with JRuby. I have completed the example with JunqueNote and Jemmy, that works fine. But now I am trying to apply the same technique to another Java application. The problem I have is when I launch the app in the test script, execution is not returned to the script.

I extracted the main jar file of the app and inspected the META-INF\MANIFEST.MF file to get the Main-Class.

I then modified jruby_basics.rb into the following test.rb which launches the app by creating an instance of the Main-Class:


require 'java'
require 'jemmy.jar'
require 'lib\guiclient.jar' #the main jar of my app

java_import 'org.netbeans.jemmy.JemmyProperties'
java_import 'org.netbeans.jemmy.TestOut'

%w(Frame TextArea MenuBar Dialog Button).each do |o|
  java_import "org.netbeans.jemmy.operators.J#{o}Operator"

JemmyProperties.set_current_timeout 'DialogWaiter.WaitDialogTimeout', 3000 
JemmyProperties.set_current_output TestOut.get_null_output

print "Start Application\n" #(4)

print "Find LoginDialog\n" #(5)
dialog = ''
button = dialog, "loginButton"

Because the app is normally launched by a batch file that passes some arguments to the JVM in order for it to run and also changes directories, I have created a test.bat file that passes the same arguments via jruby -J options:


set version="11.0.8"
set testdir=%CD%
set testlogdir=%testdir%
cd \usr\testing\GUI\%version%
jruby --1.8 -J-Xms512m -J-Xmx1024m -J-Ddebug=false -J-Dapp.dir="%CD%" -J-Dapp.log.path="%testdir%" -J-DGUI_CLIENT_VERSION=%version% %testdir%\test.rb
cd %testdir%

So this all works up until test.rb #(4). At this point the app has launched and the login dialog is displayed. But then the print statement at #(5) never appears and execution never returns to the test script.

Do you have any alternate strategies I could try for starting the app in a different way?

Cheers, Kim

14 Feb 2014, 23:41
Erin Dees (212 posts)

Hi, Kim.

Sorry to hear of the trouble. Jemmy may be having trouble matching the login dialog by its Java class; does it help to change the dialog line to the following?

dialog = 'Login Window Title'



16 Jul 2014, 02:06
Kim Faint (2 posts)

Hi Ian,

I did try changing the dialog line as you suggest. Unfortunately I think the script never gets to the dialog line as the print line before it is never printed.

05 Sep 2014, 19:06
Erin Dees (212 posts)

Hi, Kim.

Sorry for the slow reply. Would it help to spin up the main dialog in a different thread, and delay for a bit after the launch to give it time to come up?



You must be logged in to comment