Search in sources :

Example 1 with JPopupMenuFixture

use of org.fest.swing.fixture.JPopupMenuFixture in project ats-framework by Axway.

the class SwingPopupMenu method click.

/**
     * Click pop-up element
     * @throws VerificationException if the element doesn't exist
     */
@PublicAtsApi
public void click() {
    new SwingElementState(this).waitToBecomeExisting();
    ((JPopupMenuFixture) SwingElementLocator.findFixture(this)).click();
}
Also used : JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 2 with JPopupMenuFixture

use of org.fest.swing.fixture.JPopupMenuFixture in project ats-framework by Axway.

the class SwingMultiSelectList method rightClick.

/**
     *
     * @param contextMenuItems context menu items to select
     */
@PublicAtsApi
public void rightClick(String... contextMenuItems) {
    new SwingElementState(this).waitToBecomeExisting();
    JListFixture listFixture = ((JListFixture) SwingElementLocator.findFixture(this));
    JPopupMenuFixture popUpMenu = listFixture.showPopupMenu();
    popUpMenu.menuItemWithPath(contextMenuItems).click();
}
Also used : JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) JListFixture(org.fest.swing.fixture.JListFixture) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with JPopupMenuFixture

use of org.fest.swing.fixture.JPopupMenuFixture in project android by JetBrains.

the class ChooseDeviceDefinitionStepFixture method deleteHardwareProfile.

@NotNull
public ChooseDeviceDefinitionStepFixture deleteHardwareProfile(@NotNull final String deviceName) {
    JTableFixture deviceListFixture = getTableFixture();
    deviceListFixture.cell(deviceName).click(RIGHT_BUTTON);
    JPopupMenuFixture contextMenuFixture = new JPopupMenuFixture(robot(), robot().findActivePopupMenu());
    contextMenuFixture.menuItemWithPath("Delete").click();
    MessagesFixture.findByTitle(robot(), "Confirm Deletion").clickYes();
    Wait.seconds(1).expecting("device to be deleted").until(() -> !deviceNames().contains(deviceName));
    return this;
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with JPopupMenuFixture

use of org.fest.swing.fixture.JPopupMenuFixture in project ats-framework by Axway.

the class SwingElementLocator method findFixture.

public static ComponentFixture<? extends Component> findFixture(UiElement uiElement) {
    SwingDriverInternal driver = (SwingDriverInternal) uiElement.getUiDriver();
    ContainerFixture<?> containerFixture = (ContainerFixture<?>) driver.getActiveContainerFixture();
    Class<? extends Component> componentClass = componentsMap.get(uiElement.getClass());
    try {
        if (componentClass.equals(JButton.class)) {
            return (ComponentFixture<? extends Component>) new JButtonFixture(containerFixture.robot, (JButton) findElement(uiElement));
        } else if (componentClass.equals(JTextComponent.class)) {
            return (ComponentFixture<? extends Component>) new JTextComponentFixture(containerFixture.robot, (JTextComponent) findElement(uiElement));
        } else if (componentClass.equals(JMenuItem.class)) {
            if (uiElement.getElementProperty("path") != null) {
                return containerFixture.menuItemWithPath(uiElement.getElementProperty("path").split("[\\,\\/]+"));
            } else {
                return (ComponentFixture<? extends Component>) new JMenuItemFixture(containerFixture.robot, (JMenuItem) findElement(uiElement));
            }
        } else if (componentClass.equals(JPopupMenu.class)) {
            return (ComponentFixture<? extends Component>) new JPopupMenuFixture(containerFixture.robot, (JPopupMenu) findElement(uiElement));
        } else if (componentClass.equals(JTree.class)) {
            return (ComponentFixture<? extends Component>) new JTreeFixture(containerFixture.robot, (JTree) findElement(uiElement));
        } else if (componentClass.equals(JList.class)) {
            return (ComponentFixture<? extends Component>) new JListFixture(containerFixture.robot, (JList) findElement(uiElement));
        } else if (componentClass.equals(JCheckBox.class)) {
            return (ComponentFixture<? extends Component>) new JCheckBoxFixture(containerFixture.robot, (JCheckBox) findElement(uiElement));
        } else if (componentClass.equals(JToggleButton.class)) {
            return (ComponentFixture<? extends Component>) new JToggleButtonFixture(containerFixture.robot, (JToggleButton) findElement(uiElement));
        } else if (componentClass.equals(JComboBox.class)) {
            return (ComponentFixture<? extends Component>) new JComboBoxFixture(containerFixture.robot, (JComboBox) findElement(uiElement));
        } else if (componentClass.equals(JRadioButton.class)) {
            return (ComponentFixture<? extends Component>) new JRadioButtonFixture(containerFixture.robot, (JRadioButton) findElement(uiElement));
        } else if (componentClass.equals(JTable.class)) {
            return (ComponentFixture<? extends Component>) new JTableFixture(containerFixture.robot, (JTable) findElement(uiElement));
        } else if (componentClass.equals(JSpinner.class)) {
            return (ComponentFixture<? extends Component>) new JSpinnerFixture(containerFixture.robot, (JSpinner) findElement(uiElement));
        } else if (componentClass.equals(JTabbedPane.class)) {
            return (ComponentFixture<? extends Component>) new JTabbedPaneFixture(containerFixture.robot, (JTabbedPane) findElement(uiElement));
        } else if (componentClass.equals(JOptionPane.class)) {
            return (ComponentFixture<? extends Component>) containerFixture.optionPane();
        } else if (componentClass.equals(JLabel.class)) {
            return (ComponentFixture<? extends Component>) new JLabelFixture(containerFixture.robot, (JLabel) findElement(uiElement));
        } else if (componentClass.equals(Component.class)) {
            return new ComponentFixture<Component>(containerFixture.robot, findElement(uiElement)) {
            };
        } else if (componentClass.equals(JFileChooser.class)) {
            // TODO - might be searched by name too
            return containerFixture.fileChooser(Timeout.timeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()));
        } else {
            throw new ElementNotFoundException(uiElement.toString() + " not found. No such Fixture");
        }
    } catch (ComponentLookupException cle) {
        throw new ElementNotFoundException(uiElement.toString() + " not found.", cle);
    } catch (WaitTimedOutError exc) {
        // thrown for OptionPane search, wait for Window (BasicRobot.waitForWindow), AbstractJTableCellWriter, JTreeDriver.waitForChildrenToShowUp, each Pause wait
        throw new ElementNotFoundException(uiElement.toString() + " not found.", exc);
    }
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JRadioButton(javax.swing.JRadioButton) SwingDriverInternal(com.axway.ats.uiengine.internal.driver.SwingDriverInternal) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextComponent(javax.swing.text.JTextComponent) JSpinnerFixture(org.fest.swing.fixture.JSpinnerFixture) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) JLabelFixture(org.fest.swing.fixture.JLabelFixture) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JButtonFixture(org.fest.swing.fixture.JButtonFixture) JToggleButtonFixture(org.fest.swing.fixture.JToggleButtonFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) JToggleButton(javax.swing.JToggleButton) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) ComponentFixture(org.fest.swing.fixture.ComponentFixture) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) JMenuItem(javax.swing.JMenuItem) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) JRadioButtonFixture(org.fest.swing.fixture.JRadioButtonFixture) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JOptionPane(javax.swing.JOptionPane) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) JListFixture(org.fest.swing.fixture.JListFixture) ContainerFixture(org.fest.swing.fixture.ContainerFixture) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JCheckBoxFixture(org.fest.swing.fixture.JCheckBoxFixture) JList(javax.swing.JList)

Example 5 with JPopupMenuFixture

use of org.fest.swing.fixture.JPopupMenuFixture in project ats-framework by Axway.

the class SwingPopupMenu method getVisibleMenuLabels.

/**
     * Getting only visible menu labels/texts
     *
     * @return an array with the visible menu labels/texts only
     */
@PublicAtsApi
public String[] getVisibleMenuLabels() {
    new SwingElementState(this).waitToBecomeExisting();
    JPopupMenuFixture popupMenuFixture = (JPopupMenuFixture) SwingElementLocator.findFixture(this);
    String[] labels = popupMenuFixture.menuLabels();
    List<String> visibleLabels = new ArrayList<String>(labels.length);
    for (final String label : labels) {
        JMenuItemFixture menuItemFixture = popupMenuFixture.menuItem(new GenericTypeMatcher<JMenuItem>(JMenuItem.class, false) {

            @Override
            protected boolean isMatching(JMenuItem menuItem) {
                String text = menuItem.getText();
                if (text != null && text.equals(label)) {
                    return true;
                }
                return false;
            }
        });
        if (menuItemFixture != null && menuItemFixture.component().isVisible()) {
            visibleLabels.add(label);
        }
    }
    return visibleLabels.toArray(new String[0]);
}
Also used : JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) ArrayList(java.util.ArrayList) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) JMenuItem(javax.swing.JMenuItem) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

JPopupMenuFixture (org.fest.swing.fixture.JPopupMenuFixture)9 PublicAtsApi (com.axway.ats.common.PublicAtsApi)5 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)5 JTreeFixture (org.fest.swing.fixture.JTreeFixture)4 JTableFixture (org.fest.swing.fixture.JTableFixture)3 JMenuItem (javax.swing.JMenuItem)2 JListFixture (org.fest.swing.fixture.JListFixture)2 JMenuItemFixture (org.fest.swing.fixture.JMenuItemFixture)2 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)1 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)1 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 TableView (com.intellij.ui.table.TableView)1 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1