How does the widget finding algorithm work?
The widget finder searches the current active window for matches. Locators might match mutiple widgets (whether this case is exceptional depends on whether you use IUIContext.find(..) or IUIContext.findAll(..)). As a simple example, new ButtonLocator(“OK”) identifies a Button labeled “OK” in the current active window. If there is more than one such button in the active window, you can disambiguate the search by embellishing the locator with information about the Button’s location in the widget containment hierarchy. For instance, if the “OK” button of interest is the child of a Composite (and none other is), new ButtonLocator(“OK”, new SWTWidgetLocator(Composite.class)) will uniquely identify it. Whereever possible, you should name widgets that require disambiguation. See …. for more on this. For more on matching by containment look at the SWTWidgetLocator javadocs.