use of org.fest.swing.fixture.JMenuItemFixture 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]);
}
Aggregations