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