The information in this topic may be out of date. The current SDK reference guide has moved here.

locate method

Class: EyesPlatform: AppiumLanguage: Java SDK:

Use this method to search the current browser viewport for one or more graphics regions defined by visual locators.


List<String> names_A = Arrays.asList(new String[]{"locator_1a", "locator_1b", "locator_1c"});
Map<String, List<Region>> locRegions5 = eyes.locate(VisualLocator.names(names_A).first()); 


An object that defines the required visual locator names and how many instances of each locator should be found. This object is created using a series of calls on a VisualLocator object in a fluent API style. See the example below for more details.

Return value

Type: Map<String, List<Region>>

Returns a mapping between the locator names passed as a parameter name or names methods and the regions in the viewport where the graphic images defined by those locator names were detected.

If the image of a particular locator name is not found in the viewport, the locator is mapped to a zero length array. If a locator name is passed, and a locator of that name has not been defined on the Eyes server, the returned locator will be mapped to a value of null instead of an array.

and each value is an object that contains the text found and its bounding rectangle.


The article Visual locators describes in detail how to associate locator names with graphic images and how to search for instances of the graphic in the browser viewport. The example below is a briefer description of how to search for instances of the locator graphics.


The example below includes two calls to the method Eyes.locate. These calls illustrate two ways to specify the visual locators and two ways to specify how many locators to return.

Two ways of specifying visual locators are:

  • Pass a locator string to the method name.
  • Pass a list of strings to the method names.

You can call these methods multiple times to specify multiple locators names or multiple lists of locator names.

To specify how many regions to return per locator, append one of the following methods:

  • To retrieve a maximum of one region for each locator append a call to first.
  • To retrieve all regions for all locators append a call to (all).
//return a zero or one locator for each of the three locators defined as parameters to name()
Map<String, List<Region>> locRegions8 = eyes.locate("locator_a")
//return all the locator found for the locators defined in the lists passed to names() or Strings passed to name()                   
List<String> locatorList1 = Arrays.asList(new String[]{"locator_1a", "locator_1b", "locator_1c"});
List<String> locatorList2 = Arrays.asList(new String[]{"locator_2a", "locator_2b", "locator_2c"});
Map<String, List<Region>> locRegions9 = eyes.locate(
                 .name("another locator")
//loop through all the locators and click on the center of their region
locRegions7.forEach((locator,regions)-> {
    for (Region region : regions) {
        click(region.getLeft()+region.getWidth()/2, region.getTop()+region.getHeight()/2);