private boolean closePossibleDialog() { JDialogOperator operator; try { operator = new JDialogOperator(); } catch (TimeoutExpiredException e) { return false; } System.out.println("Closed dialog '" + operator.getTitle() + "'."); operator.close(); return true; } }
/** * Close dialogs * * @param dialog find all dialogs of owner for this dialog * @param chooser chooser used for looking for dialogs */ private static void closeDialogs(javax.swing.JDialog dialog, org.netbeans.jemmy.ComponentChooser chooser) { for (Window window : dialog.getOwnedWindows()) { if (chooser.checkComponent(window)) { closeDialogs((javax.swing.JDialog) window, chooser); } } new org.netbeans.jemmy.operators.JDialogOperator(dialog).requestClose(); }
/** * Close dialogs * * @param dialog find all dialogs of owner for this dialog * @param chooser chooser used for looking for dialogs */ private static void closeDialogs(javax.swing.JDialog dialog, org.netbeans.jemmy.ComponentChooser chooser) { for (Window window : dialog.getOwnedWindows()) { if (chooser.checkComponent(window)) { closeDialogs((javax.swing.JDialog) window, chooser); } } new org.netbeans.jemmy.operators.JDialogOperator(dialog).requestClose(); }
/** * push a button in a given container and wait for the dialog to open * * @param operator * the operator to find the button in * @param buttonName * the name of the button to push * @param dialogName * the dialog that should appear * @return the JDialogOperator of the requested dialog or null if not opened * * @throws Exception */ public JDialogOperator pushButtonAndWaitForDialog( ContainerOperator operator, String buttonName, String dialogName) throws Exception { pushButton(operator, (Object) buttonName); JDialogOperator dialog = new JDialogOperator(dialogName); if (dialog == null || !dialog.isActive()) { report("The Dialog " + dialogName + " was not opened successfully", Reporter.WARNING); return null; } report("The Dialog " + dialogName + " was opened successfully"); return dialog; }
/** * This method is designed to choose a menu item and wait for a dialog window to be opened. * The method also activates a retry mechanism until the dialog is successfully opened. * * @param windowName * The window that holds the menu (Label of the window) * @param buttonName * The menu item name to be selected * @param mainWindow * The dialog window that will be opened. * @throws Exception */ public DialogOperator chooseMenuItemAndWaitForDialog( JFrameOperator mainFrame, String menuName, String menuItemName, String dialogName) throws Exception { chooseMenuItem(mainFrame, menuName, menuItemName); JDialogOperator dialog = new JDialogOperator(dialogName); if (!dialog.isActive()) { report("The Dialog " + dialogName + " was not opened successfully. is visible = " + dialog.isVisible()); Thread.sleep(1000); report("The Dialog " + dialogName + " after 1 second sleep active = " + dialog.isActive() + " is visible = " + dialog.isVisible()); } else { report("The Dialog " + dialogName + " was opened successfully"); } return dialog; }
/** * get a JDialogOperator object if it is open * * @param title * the Dialog title * @param secondsToWait * how many seconds to wait for the dialog to appear * @return */ public JDialogOperator getDialogIfExists(String title, int secondsToWait) { DialogWaiter waiter = new DialogWaiter(); waiter.getTimeouts().setTimeout("DialogWaiter.WaitDialogTimeout", secondsToWait * 1000); JDialogOperator dialog; try { waiter.waitDialog(new ComponentChooserHelper(title)); dialog = new JDialogOperator(new ComponentChooserHelper(title)); } catch (Exception e) { return null; } return dialog; }
System.out.println("button is enabled = " + btn.isEnabled()); btn.push(); JDialogOperator dialog = new JDialogOperator(windowName); if (!dialog.isActive()) { this.report("The Dialog " + windowName
/** * Shows and hides the EnhancedPanel instance several times in a * JOptionPane and counts these events. */ @Test public void testEvents4JOptionPane() throws Exception { final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l); final String title = EnhancedPanelIT.class.getSimpleName(); final Runnable makeVisible = new Runnable() { @Override public void run() { JOptionPane.showMessageDialog( null, instance, title, JOptionPane.INFORMATION_MESSAGE); } }; for (int i = 1; i <= 3; i++) { runOnEdt(makeVisible); final JDialogOperator dialog = new JDialogOperator(title); // wait for JOptionPane assertEquals(i, l.shown); assertEquals(i - 1, l.hidden); final JButtonOperator button = new JButtonOperator(dialog); button.push(); button.getQueueTool().waitEmpty(WAIT_EMPTY); assertEquals(i, l.shown); assertEquals(i, l.hidden); } }