• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jemmy Question

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I am a java newbie trying to do some basic java GUI automation testing. I am using Jemmy, but the Jemmy API's I am calling are not finding the app I am launching. The app launches ok, but I am not sure I launched it correctly. The Jemmy example code uses ClassReference(...).startApplication() but I instead used getRuntime().exec(). Also, I am not sure I am calling the correct function to locate the dialog that is launched. The Jemmy example code uses, JFrameOperator(), but since the class of the dialog I am looking for is SunAwtDialog, I am trying to use JDialogOperator.getTopModalDialog() or JDialogOperator.findJDialog().

here is my code:
import org.netbeans.jemmy.*;
import org.netbeans.jemmy.explorer.*;
import org.netbeans.jemmy.operators.*;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.awt.Dialog;
import java.lang.Thread;


public class WaitWindowSample implements Scenario {

public String AppPath = "C:\\myapp.exe";
public int runIt(Object param) {
try {
//start application
//new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser").startApplication();
Process proc = Runtime.getRuntime().exec(AppPath);

//wait frame
//new JFrameOperator("GUI Browser");

Thread.sleep(5000);
Dialog modalDialog = JDialogOperator.getTopModalDialog();

if(modalDialog == null)
modalDialog = JDialogOperator.findJDialog("Evaluation Notice", false, false);

if(modalDialog == null)
JOptionPane.showMessageDialog(new JFrame(), "Dialog Not Found");
else
JOptionPane.showMessageDialog(new JFrame(), modalDialog.getName());

JOptionPane.showMessageDialog(new JFrame(), "Done");
} catch(Exception e) {
e.printStackTrace();
return(1);
}
return(0);
}
public static void main(String[] argv) {

String[] params = {"WaitWindowSample"};
org.netbeans.jemmy.Test.main(params);
}
}

And here is the original sample code:
https://jemmy.dev.java.net/samples.html
https://jemmy.dev.java.net/samples/WaitWindowSample.java
 
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The only way to use Jemmy library is launching your application with new ClassReference("<Main application class>").startApplication(); instruction.
Your application and tested application should run in the same JVM, because Jemmy uses Reflection to get access to GUI.
This approach can be quite complicated for big applications, because you need to know how applications starts and initializes.

Good luck.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic