Eyes class
This class provides the main methods used to execute tests and checkpoints.
Eyes method
Syntax
let eyes = new Eyes(runner);
let eyes = new Eyes();
Parameters
runner
Type: EyesRunner [Optional ]
If this parameter is provided, it must be an instance of either the ClassicRunner
or VisualGridRunner
classes. If a VisualGridRunner
is passed then the image will be rendered using the Ultrafast Grid. If this parameter is not provided, then DOM rendering is done using the local browser defined by the driver parameter passed to the Eyes.open
method.
Return value
Type: Eyes
Use the object returned to call the various methods provided by the Eyes class.
abort method
Syntax
let result = await eyes.abort();
Parameters
This method does not take any parameters.
Return value
Type: Promise<
TestResults\>
Remarks
If you call this method on a test that was opened but not closed, then then test will have an aborted status in the Eyes Test Manager. If you call it after the test has been successfully closed, then the call is ignored.
addProperty method
Syntax
let value = eyes.addProperty(name, value);
Parameters
name
Type: string
The name of the property.
value
Type: string
The value associated with the name.
Return value
Type: Configuration
Remarks
- Set multiple properties by calling
Eyes.addProperty
orConfiguration.addProperty
multiple times with the same property name and with different values. - You should not assign a given value to a property more than once in a given test run.
- You can also associate properties with a batch using
BatchInfo.addProperty
.
check method
Syntax
let result = await eyes.check(name, checkSettings_obj);
let result = await eyes.check(checkSettings_lit);
let result = await eyes.check();
Parameters
name
Type: string
The tag defines a name for the checkpoint in the Eyes Test Manager. The name may be any string and serves to identify the step to the user in the Test manager. You may change the tag value without impacting testing in any way since Eyes does not use the tag to identify the baseline step that corresponds to the checkpoint - Eyes matches steps based on their content and position in the sequences of images of the test. See How Eyes compares checkpoints and baseline images for details.
checkSettings_obj
Type: CheckSettings
The fluent API calls, starting with one of the Target
methods.
A series of method calls to the CheckSettings class, in Fluent API style.
checkSettings_lit
Type: CheckSettingsPlain
[Optional ]
The fluent API calls, starting with one of the Target
methods.
A literal object defined by the CheckSettingsPlain object.
Return value
Type: Promise<
MatchResult\>
clearProperties method
Syntax
let value = eyes.clearProperties();
Parameters
This method does not take any parameters.
Return value
Type: Configuration
close method
Syntax
let result = await eyes.close(throwErr);
let result = await eyes.close();
Parameters
throwErr
Type: boolean [Optional ]
If this parameter has a value of true, then if there are new, missing, or mismatched steps, an exception will be thrown. If the parameter is set to false, then an exception will not be thrown for the above cases. If the parameter is not passed, then it is as if a true value was passed.
Return value
Type: Promise<
TestResults\>
The result of the test can be obtained from the object returned.
getApiKey method
Syntax
let value = eyes.getApiKey();
Parameters
This method does not take any parameters.
Return value
Type: string
getAppName method
Syntax
let value = eyes.getAppName();
Parameters
This method does not take any parameters.
Return value
Type: string
getBaselineBranchName method
Syntax
let value = eyes.getBaselineBranchName();
Parameters
This method does not take any parameters.
Return value
Type: string
getBaselineEnvName method
Syntax
let value = eyes.getBaselineEnvName();
Parameters
This method does not take any parameters.
Return value
Type: string
Returns the value most recently set by a call to setBaselineEnvName
, or a value of null if the baseline environment name has not been assigned in this run.
getBatch method
Syntax
let value = eyes.getBatch();
Parameters
This method does not take any parameters.
Return value
Type: BatchInfo
getBranchName method
Syntax
let value = eyes.getBranchName();
Parameters
This method does not take any parameters.
Return value
Type: string
getConfiguration method
Syntax
let value = eyes.getConfiguration();
eyes.configuration = value;
value = eyes.configuration;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: Configuration
getDebugScreenshotsPath method
Syntax
let value = eyes.getDebugScreenshotsPath();
Parameters
This method does not take any parameters.
Return value
Type: string
Remarks
Enable and disable saving screenshots to the local disk using the setSaveDebugScreenshots
method.
getDebugScreenshotsPrefix method
Syntax
let value = eyes.getDebugScreenshotsPrefix();
Parameters
This method does not take any parameters.
Return value
Type: string
Remarks
Enable and disable saving screenshots to the local disk using the setSaveDebugScreenshots
method.
getDeviceInfo method
Syntax
let value = eyes.getDeviceInfo();
Parameters
This method does not take any parameters.
Return value
Type: string
getDriver method
Syntax
let value = eyes.getDriver();
value = eyes.driver;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: ProtractorBrowser
getForceFullPageScreenshot method
Syntax
let value = eyes.getForceFullPageScreenshot();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getHideCaret method
Syntax
let value = eyes.getHideCaret();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getHideScrollbars method
Syntax
let value = eyes.getHideScrollbars();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getHostApp method
Syntax
let value = eyes.getHostApp();
Parameters
This method does not take any parameters.
Return value
Type: string
getHostOS method
Syntax
let value = eyes.getHostOS();
Parameters
This method does not take any parameters.
Return value
Type: string
getIgnoreCaret method
Syntax
let value = eyes.getIgnoreCaret();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getIsDisabled method
Syntax
let value = eyes.getIsDisabled();
Parameters
This method does not take any parameters.
Return value
Type: boolean
If true, then all calls to Eyes are ignored, if false then all calls to Eyes work as usual.
getIsOpen method
Syntax
let value = eyes.getIsOpen();
value = eyes.getIsOpen;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: boolean
Return true if the Eyes.open
method has been called on an eyes instance, and Eyes.close
or Eyes.abort
have not yet been called.
getMatchLevel method
Syntax
let value = eyes.getMatchLevel();
Parameters
This method does not take any parameters.
Return value
Type: MatchLevel
Remarks
For a full description of the affect of each match levels and the different ways to apply them to tests, checkpoints and regions, How to use Eyes match levels.
getMatchTimeout method
Syntax
let value = eyes.getMatchTimeout();
Parameters
This method does not take any parameters.
Return value
Type: number
getParentBranchName method
Syntax
let value = eyes.getParentBranchName();
Parameters
This method does not take any parameters.
Return value
Type: string
getProxy method
Syntax
let value = eyes.getProxy();
Parameters
This method does not take any parameters.
Return value
Type: ProxySettings
getRotation method
Syntax
let value = eyes.getRotation();
Parameters
This method does not take any parameters.
Return value
Type: ImageRotation
The rotation in degrees.
getSaveDebugScreenshots method
Syntax
let value = eyes.getSaveDebugScreenshots();
Parameters
This method does not take any parameters.
Return value
Type: boolean
Remarks
Enable and disable saving screenshots to the local disk using the setSaveDebugScreenshots
method.
getSaveDiffs method
Syntax
let value = eyes.getSaveDiffs();
Parameters
This method does not take any parameters.
Return value
Type: boolean
returns true if steps that have mismatches are automatically saved to the baseline.
getSaveNewTests method
Syntax
let value = eyes.getSaveNewTests();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getScaleRatio method
Syntax
let value = eyes.getScaleRatio();
Parameters
This method does not take any parameters.
Return value
Type: number
getScrollRootElement method
Syntax
let value = eyes.getScrollRootElement();
Parameters
This method does not take any parameters.
Return value
Type:
Element|Selector
Returns either the value most recently set using Eyes.setScrollRootElement
, or returns an undefined value if this method was not called.
Type definitions
Element
Used to identify an HTML element defined as import('selenium-webdriver').WebElement|import('protractor').ElementFinder.
Selector
Used to identify an HTML element defined as |import('protractor').Locator|{using:string;value:string}|string|{selector:string;**Type:** string}
.
getSendDom method
Syntax
let value = eyes.getSendDom();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getServerUrl method
Syntax
let value = eyes.getServerUrl();
Parameters
This method does not take any parameters.
Return value
Type: string
getStitchMode method
Syntax
let value = eyes.getStitchMode();
Parameters
This method does not take any parameters.
Return value
Type: StitchMode
The value returned can be either CSS
or SCROLL
.
getStitchOverlap method
Syntax
let value = eyes.getStitchOverlap();
Parameters
This method does not take any parameters.
Return value
Type: number
The stitching overlap in pixels.
getViewportSize method
Syntax
let result = await eyes.getViewportSize();
Parameters
This method does not take any parameters.
Return value
Type: Promise<
RectangleSize\>
getWaitBeforeScreenshots method
Syntax
let value = eyes.getWaitBeforeScreenshots();
Parameters
This method does not take any parameters.
Return value
Type: number
The time Eyes waits before taking a screenshot, in milliseconds.
locate method
Syntax
Call syntax
let regions = eyes.locate({ locatorNames: ["locA", "locB"], firstOnly: false });
Declaration
<TLocator extends string>(settings:VisualLocatorSettings<TLocator>):Promise<Record<TLocator,RegionPlain[]>>
Parameters
settings
Type: VisualLocatorSettings``<TLocator>
A literal object that defines the required visual locator names and whether a single or all instances of each locator should be found. See the example below for more details.
Return value
Type: Promise<Record<TLocator,RegionPlain\[\]>>
Returns a mapping between the names passed in the locatornames field passed as a parameter and the regions in the viewport where the graphic images defined by those locator names were detected. If the firstOnly parameter is passed and has a value of true then only the 1st result found is retuned.
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.
Type definitions
RegionPlain
Used to describe a position and rectangular region in an image. RegionPlain is defined as: LocationPlain
&RectangleSizePlain
Remarks
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.