Skip to main content

Target class

This class provides methods that are used to define the top level target (the entire window, region, element, frame, etc.) for the check method.

Once you create a EspressoCheckSettings object using one of the factory methods defined by this class, you can configure the checkpoint by calling other methods from the EspressoCheckSettings class, chaining them one after the other using the '.' operator.

Import statement

import com.applitools.eyes.android.espresso.fluent.Target;

fragment method

Syntax

eyes.check(Target.fragment())

Note: This method is a static method.

Parameters

This method does not take any parameters.

Return value

Type: EspressoCheckSettings

Remarks

The id of the fragment should be provided by the Fluent method id(), for example:

eyes.check(Target.fragment().id(fragId));

Handling popups and dialogs

If your checkpoints includes a popup or dialog then the way you create the checkpoint depends on which layers you want to capture as illustrated in the code below:

eyes.check('viewport only', Target.window()); 
eyes.check('dialog only',Target.window().dialog());
eyes.check('popup only',Target.window().popup());
eyes.check('viewport and popup or dialog',Target.window().includeAllLayers());

The example illustrate the behavior with a Target.window target, but they apply to a Target.region, Target.googleMap or Target.fragment as well.

googleMap method

Syntax

eyes.check(Target.googleMap().id(mapId);

Note: This method is a static method.

Parameters

This method does not take any parameters.

Return value

Type: EspressoCheckSettings

Remarks

The id of the googlemap should be provided by the Fluent method id(), for example:

eyes.check(Target.googleMap().id(mapId)If the googleMap is not of the type `SupportMapFragment` then you should also call [isNotSupportGoogleMap](/docs/api-ref/sdk-api/espresso/java/checksettings#isnotsupportgooglemap-method).

eyes.check(Target.googleMap().id(mapId).isNotSupportGoogleMap();

Handling popups and dialogs

If your checkpoints includes a popup or dialog then the way you create the checkpoint depends on which layers you want to capture as illustrated in the code below:

eyes.check('viewport only', Target.window()); 
eyes.check('dialog only',Target.window().dialog());
eyes.check('popup only',Target.window().popup());
eyes.check('viewport and popup or dialog',Target.window().includeAllLayers());

The example illustrate the behavior with a Target.window target, but they apply to a Target.region, Target.googleMap or Target.fragment as well.

region method

Syntax

eyes.check(Target.region(region))
eyes.check(Target.region(matcher))
eyes.check(Target.region(view))

Note: This method is a static method.

Parameters

region

Type: Region

The region to be checked.

matcher

Type: Matcher

The Matcher types can be any of the following Hamcrest Matchers: ViewMatcher, RootMatcher, LayoutMatcher or PreferenceMatcher

view

Type: View

An instance of the Android view class

Return value

Type: EspressoCheckSettings

Remarks

Handling popups and dialogs

If your checkpoints includes a popup or dialog then the way you create the checkpoint depends on which layers you want to capture as illustrated in the code below:

eyes.check('viewport only', Target.window()); 
eyes.check('dialog only',Target.window().dialog());
eyes.check('popup only',Target.window().popup());
eyes.check('viewport and popup or dialog',Target.window().includeAllLayers());

The example illustrate the behavior with a Target.window target, but they apply to a Target.region, Target.googleMap or Target.fragment as well.

window method

Syntax

eyes.check(Target.window())

Note: This method is a static method.

Parameters

This method does not take any parameters.

Return value

Type: EspressoCheckSettings

Remarks

Handling popups and dialogs

If your checkpoints includes a popup or dialog then the way you create the checkpoint depends on which layers you want to capture as illustrated in the code below:

eyes.check('viewport only', Target.window()); 
eyes.check('dialog only',Target.window().dialog());
eyes.check('popup only',Target.window().popup());
eyes.check('viewport and popup or dialog',Target.window().includeAllLayers());

The example illustrate the behavior with a Target.window target, but they apply to a Target.region, Target.googleMap or Target.fragment as well.