Search in sources :

Example 1 with SingleComponentHierarchy

use of org.fest.swing.hierarchy.SingleComponentHierarchy in project ats-framework by Axway.

the class SwingElementFinder method find.

public static <T extends Component> T find(Robot robot, Container root, GenericTypeMatcher<T> m) {
    ComponentHierarchy hierarchy = robot.hierarchy();
    List<Component> found = null;
    if (root == null) {
        found = find(hierarchy, m);
    } else {
        found = find(new SingleComponentHierarchy(root, hierarchy), m);
    }
    if (found.isEmpty()) {
        throw componentNotFound(robot, hierarchy, m);
    }
    if (found.size() > 1) {
        throw multipleComponentsFound(found, m);
    }
    Component component = found.iterator().next();
    return m.supportedType().cast(component);
}
Also used : SingleComponentHierarchy(org.fest.swing.hierarchy.SingleComponentHierarchy) ComponentHierarchy(org.fest.swing.hierarchy.ComponentHierarchy) SingleComponentHierarchy(org.fest.swing.hierarchy.SingleComponentHierarchy) Component(java.awt.Component)

Aggregations

Component (java.awt.Component)1 ComponentHierarchy (org.fest.swing.hierarchy.ComponentHierarchy)1 SingleComponentHierarchy (org.fest.swing.hierarchy.SingleComponentHierarchy)1