07 Jan 2014, 07:11
Generic-user-small

Kim Faint (1 post)

Hi,

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:

test.rb

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"
end

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

print "Start Application\n"
com.example.app.gui.client.Driver.new #(4)

print "Find LoginDialog\n" #(5)
dialog = JDialogOperator.new 'com.example.app.gui.client.gui.dialog.LoginDialog.class'
button = JButtonOperator.new dialog, "loginButton"
button.push

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:

test.bat

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
Mr_sketchy_pragsmall

Ian Dees (195 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 = JDialogOperator.new 'Login Window Title'

Sincerely,

Ian

  You must be logged in to comment