//: test_scenario/ScenarioByFile.java package test_scenario; import swing.*; import org.netbeans.jemmy.*; import org.netbeans.jemmy.operators.*; /** * Testing Swing application by Jemmy ver 2 toolkit * Using file to get parameters * @author Shpatserman Maria */ public class ScenarioByFile implements Scenario{ public int runIt(Object param) { try { //Get names Frames, button e t.c. from file //load bundle Bundle bundle = new Bundle(); bundle.loadFromFile("/home/java/properties_for_test"); //start application new ClassReference(bundle.getResource("main_class")).startApplication(); //wait frame JFrameOperator mainFrame = new JFrameOperator(bundle.getResource("main_window")); //wait for queue to be empty new QueueTool().waitEmpty(200); //Find button by name(text) JButtonOperator firstButton = new JButtonOperator(mainFrame, bundle.getResource("first_button")); firstButton.push(); new QueueTool().waitEmpty(200); //Find TextField with text ( after push() the First button JTextFieldOperator textField = new JTextFieldOperator(mainFrame,bundle.getResource("find_text_field")); new QueueTool().waitEmpty(200); //Clear Text textField.clearText(); new QueueTool().waitEmpty(200); //type text + enter textField.enterText(bundle.getResource("test_data1")); new QueueTool().waitEmpty(400); //Find label by text new JLabelOperator(mainFrame,bundle.getResource("test_data1")); //Find second textField by index JTextFieldOperator textField2 = new JTextFieldOperator(mainFrame,1); textField2.enterText(bundle.getResource("test_data2")); //Find label by text new JLabelOperator(mainFrame,bundle.getResource("test_data2")); new QueueTool().waitEmpty(400); JButtonOperator secondButton = new JButtonOperator(mainFrame, bundle.getResource("second_button")); secondButton.push(); new QueueTool().waitEmpty(200); System.out.println("TextField2 = "+textField2.getText()); if (textField2.getText().equals(bundle.getResource("check_text_field2"))){ System.out.println("textField 2 OK!!!"); } mainFrame.close(); } catch(Exception e) { e.printStackTrace(); return(1); } return(0); } public static void main(String [] argv){ String[] params = {"test_scenario.ScenarioByFile"}; org.netbeans.jemmy.Test.main(params); } }