Configuration class
Introduction
This class is used to create a configuration object that is used to configure an Eyes
object by passing it to the Eyes.setConfiguration
method.
You can use this configuration object instead of using the various Eyes
methods and properties that set the same attributes. Typically you set up a Configuration object by calling its setXXXX methods chained with a '.' in a Fluent coding style. In this class, some attributes can be set by both a property and a set command. The properties allow you simple direct access to assign to and retrieve the attribute. The corresponding set method allows you to set multiple attributes using a Fluent style.
Methods and Properties
Configuration method
Syntax
let config = new Configuration();
Parameters
This method does not take any parameters.
Return value
Type: Configuration
The value returned is the object that called the method. This allows you to use a fluent style to call the setXXXX
methods of the Configuration
class.
agentId property
Syntax
config.agentId = configval;
configval = config.agentId;
Type: string
The agent id to be configured.
apiKey property
Syntax
config.apiKey = configval;
configval = config.apiKey;
Type: string
Your API key.
Remarks
Set this immediately after the Eyes object is created (before calling open
). If you have an environment variable called APPLITOOLS_API_KEY that is set to the value of your API key, then you do not need to call this method, and Eyes will take the string from the environment value.
appName property
Syntax
config.appName = configval;
configval = config.appName;
Type: string
The application name to be configured for the test.
Remarks
If you call this method, it must be called before the call to Eyes.open
. In the call to Eyes.open
, if you provide the application parameter, then it will override the value set here. If you don't provide the parameter or pass a null, then the value set here will be used.
baselineBranchName property
Syntax
config.baselineBranchName = configval;
configval = config.baselineBranchName;
Type: string
The baseline branch name to be configured.
baselineEnvName property
Syntax
config.baselineEnvName = configval;
configval = config.baselineEnvName;
Type: string
The name of the baseline environment.
batch property
Syntax
config.batch = configval;
configval = config.batch;
Type: BatchInfoPlain
An object that defines the batch configuration.
branchName property
Syntax
config.branchName = configval;
configval = config.branchName;
Type: string
The branch name to be used by the configuration.
browsersInfo property
Syntax
let suiteConfig = {
browsersInfo: [
{ height: value1_number, width: value2_number, name: "chrome" },
{ deviceName: "Galaxy Note 3", screenOrientation: "landscape" },
{
deviceName: "iPad (7th generation)",
iosVersion: "latest",
screenOrientation: "portrait",
},
],
};
eyes.setConfiguration(suiteConfig);
Type:
(DesktopBrowserInfo|ChromeEmulationInfo|IOSDeviceInfo)[]
forceFullPageScreenshot property
Syntax
config.forceFullPageScreenshot = configval;
configval = config.forceFullPageScreenshot;
Type: boolean
hideCaret property
Syntax
config.hideCaret = configval;
configval = config.hideCaret;
Type: boolean
If True
the cursor will be hidden before the image is captured.
Remarks
We recommend using this method instead of Eyes.setIgnoreCaret
, Configuration.setIgnoreCaret
or CheckSettings.ignoreCaret
, since this method/property eliminates cursor related artifacts instead of detecting and ignoring them.
hideScrollbars property
Syntax
config.hideScrollbars = configval;
configval = config.hideScrollbars;
Type: boolean
If True
scrollbars will be hidden.
hostApp property
Syntax
config.hostApp = configval;
configval = config.hostApp;
Type: string
The value to be used for the Host App property.
hostAppInfo property
Syntax
config.hostAppInfo = configval;
configval = config.hostAppInfo;
Type: string
hostOS property
Syntax
config.hostOS = configval;
configval = config.hostOS;
Type: string
The value to be used for the Host OS Property.
hostOSInfo property
Syntax
config.hostOSInfo = configval;
configval = config.hostOSInfo;
Type: string
matchTimeout property
Syntax
config.matchTimeout = configval;
configval = config.matchTimeout;
Type: number
The timeout to set in milliseconds.
Remarks
You can override the default timeout set by this method for a specific set checkpoint by passing a timeout to one of the check_XXXX methods that support a timeout parameter. You can also override the timeout for a specific test using the check fluent timeout
method
parentBranchName property
Syntax
config.parentBranchName = configval;
configval = config.parentBranchName;
Type: string
The parent branch name to be configured.
properties property
Syntax
config.properties = configval;
configval = config.properties;
Type: PropertyDataPlain
[]
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
.
rotation property
Syntax
config.rotation = configval;
configval = config.rotation;
Type: ImageRotationPlain
Type definitions
ImageRotationPlain
The legal values that an image may be rotated by. This may have the following values: -270|-180|-90|0|90|180|270
The number of degrees to rotate.
saveDiffs property
Syntax
config.saveDiffs = configval;
configval = config.saveDiffs;
Type: boolean
Set to true to configure Save Diffs functionality.
saveNewTests property
Syntax
config.saveNewTests = configval;
configval = config.saveNewTests;
Type: boolean
If False
, the user will need to save the baseline explicitly in the Test Manager for new tests to be saved to the baseline. If True
, Eyes will automatically create a baseline for tests with a status of 'new' (the default behavior).
sendDom property
Syntax
config.sendDom = configval;
configval = config.sendDom;
Type: boolean
If True
, DOM information will be sent. If False
, DOM information will not be sent.
Remarks
Sending DOM information is enabled by default, so use this method only if you have to disable it.
serverUrl property
Syntax
config.serverUrl = configval;
configval = config.serverUrl;
Type: string
The URL of the Eyes server. Pass a value of null to use the default cloud server.
stitchMode property
Syntax
config.stitchMode = configval;
configval = config.stitchMode;
Type:
StitchMode|'Scroll'|'CSS'
The stitch mode to use.
stitchOverlap property
Syntax
config.stitchOverlap = configval;
configval = config.stitchOverlap;
Type: number
The width of the stitch overlap in pixels.
testName property
Syntax
config.testName = configval;
configval = config.testName;
Type: string
The test name to be configured for the test.
viewportSize property
Syntax
config.viewportSize = configval;
configval = config.viewportSize;
Type: RectangleSizePlain
An object that defines the width and height of the test browser viewport in pixels.
visualGridOptions property
Syntax
config.visualGridOptions = configval;
configval = config.visualGridOptions;
Type:
{ [key: string]: any };
Remarks
The following configuration key/value pairs are currently supported:
'chromeHeadless'
Normally, the Ultrafast Grid renders its images using Headless Chrome. There are cases where the behavior of Headless Chrome is different from that of regular Chrome browser, and if the baseline was created with a regular Chrome browser, the differences will be found. Set this option to a value of false to instruct the Ultrafast Grid to use a regular Chrome browser instead of the Headless Chrome browser, so as to eliminate differences that arise because of the different types of Chrome browser.
'polyfillAdoptedStyleSheets'
Adopted Stylesheets are a way to create and distribute reusable styles when using a Shadow DOM. Adopted Stylesheets are not supported by all browsers, so their use may cause mismatches when doing cross-browser validation. By default, when the Ultrafast Grid detects that a page being checked uses Adopted Stylesheets, it will not render that checkpoint, the check will fail, and the test will be aborted. In the Test Manager, the test results for that run will have an Aborted status, and the step that failed will have a Missing status.
To enable rendering of checkpoints that include Adopted Stylesheets, and to ensure that the test can complete successfully, you need to explicitly set the Ultrafast Grid option polyfillAdoptedStyleSheets to a value of true or false:
- Setting a value of true instructs the Ultrafast Grid to polyfill Adopted Stylesheets.
- Setting a value of false instructs the Ultrafast Grid to render the page without polyfilling Adopted Stylesheets.
You can set this option globally using the method Configuration.setVisualGridOption
You can override the global value for a given checkpoint using the method CheckSettings.visualGridOption
.
waitBeforeScreenshots property
Syntax
config.waitBeforeScreenshots = configval;
configval = config.waitBeforeScreenshots;
Type: number
The time to wait in milliseconds. Passing a value of less than or equal to zero will cause the default value to be used.
addBrowser method
Syntax
let configval = config.addBrowser(browserInfo_dsktp);
let configval = config.addBrowser(browserInfo_chrm);
let configval = config.addBrowser(browserInfo_ios);
let configval = config.addBrowser(browserInfo_obj);
let configval = config.addBrowser(width, height, name);
let configval = config.addBrowser(width, height);
Parameters
browserInfo_dsktp
Type: DesktopBrowserInfo
An object that defines the attributes of the browser and the viewport.
DesktopBrowserInfo
browserInfo_chrm
Type: ChromeEmulationInfo
An object that defines the attributes of the browser and the viewport.
ChromeEmulationInfo
browserInfo_ios
Type: IOSDeviceInfo
An object that defines the attributes of the browser and the viewport.
IOSDeviceInfo
browserInfo_obj
Type:
{
deviceName: DeviceName | undefined;
screenOrientation?: ScreenOrientation | undefined;
};
An object that defines the attributes of the browser and the viewport.
{
deviceName: DeviceName | undefined;
screenOrientation?: ScreenOrientation | undefined;
};
width
Type: number
The width of the browser viewport for this target. The maximum viewport width for all browsers is 5120. If this limit is exceeded, then execution of the checkpoint will fail.
Use this in conjunction with the parameter.
height
Type: number
The height of the browser viewport for this target. There is no height limit.
Use this in conjunction with the parameter.
name
Type: BrowserType
[Optional ]
The type of browser for this target.
JavaScript
suiteConfig = new Configuration()
.addBrowser(viewPortWidth, viewPortHeight, BrowserType.CHROME)
/* ... other configurations */ ;
/*
* Assign the configuration to all newly created Eyes instances
*/
eyes = new Eyes(runner);
eyes.setConfiguration(suiteConfig);
Return value
Type: Configuration
The value returned is the object that called the method. This allows you to use a fluent style to call the setXXXX
methods of the Configuration
class.
Remarks
By default, the entire page is rendered. The viewport width and height parameters impact the baseline that is chosen, unless the baseline environment configuration has been provided. The viewport passed to the Eyes.open
method does not impact the baseline used, but could impact the page layout if the page has any viewport size-sensitive factors such as HTML, CSS or Javascript.
addBrowsers method
Syntax
let configval = config.addBrowsers(browsersInfo);
Parameters
browsersInfo
Type:
(
| DesktopBrowserInfo
| ChromeEmulationInfo
| IOSDeviceInfo
| {
deviceName: DeviceName | undefined;
screenOrientation?: ScreenOrientation | undefined;
}
)[];
One or more browser or device configuration definitions passed as an array or multiple parameters.
Return value
Type: Configuration
The value returned is the object that called the method. This allows you to use a fluent style to call the setXXXX
methods of the Configuration
class.
Remarks
You can use this method to pass a list of configurations instead of configuring each browser device individually using multiple calls to addBrowser
.
addDeviceEmulation method
Syntax
let configval = config.addDeviceEmulation(deviceName, screenOrientation);
let configval = config.addDeviceEmulation(deviceName);
Parameters
deviceName
Type: DeviceName
The name of the device, from the list of devices defined by DeviceName
.
screenOrientation
Type: ScreenOrientation
[Optional ]
Whether the device is in portrait or landscape mode.
Return value
Type: Configuration
The value returned is the object that called the method. This allows you to use a fluent style to call the setXXXX
methods of the Configuration
class.
addProperty method
Syntax
let configval = config.addProperty(name, value);
let configval = config.addProperty(prop);
Parameters
name
Type: string
The name of the property.
value
Type: string
The value associated with the name.
prop
Type: PropertyDataPlain
PropertyDataPlain
Return value
Type: Configuration
The value returned is the object that called the method. This allows you to use a fluent style to call the setXXXX
methods of the Configuration
class.
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
.
clearProperties method
Syntax
let configval = config.clearProperties();
Parameters
This method does not take any parameters.
Return value
Type: Configuration
getAccessibilityValidation method
Syntax
let configval = config.getAccessibilityValidation();
Parameters
This method does not take any parameters.
Return value
Type: AccessibilitySettings
Remarks
For more information about the Contrast advisor feature see Contrast advisor
.
getAgentId method
Syntax
let configval = config.getAgentId();
config.agentId = configval;
configval = config.agentId;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getApiKey method
Syntax
let configval = config.getApiKey();
config.apiKey = configval;
configval = config.apiKey;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getAppName method
Syntax
let configval = config.getAppName();
config.appName = configval;
configval = config.appName;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getBaselineBranchName method
Syntax
let configval = config.getBaselineBranchName();
config.baselineBranchName = configval;
configval = config.baselineBranchName;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getBaselineEnvName method
Syntax
let configval = config.getBaselineEnvName();
config.baselineEnvName = configval;
configval = config.baselineEnvName;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getBatch method
Syntax
let configval = config.getBatch();
config.batch = configval;
configval = config.batch;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: BatchInfo
getBranchName method
Syntax
let configval = config.getBranchName();
config.branchName = configval;
configval = config.branchName;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getDeviceInfo method
Syntax
let configval = config.getDeviceInfo();
config.deviceInfo = configval;
configval = config.deviceInfo;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getForceFullPageScreenshot method
Syntax
let configval = config.getForceFullPageScreenshot();
config.forceFullPageScreenshot = configval;
configval = config.forceFullPageScreenshot;
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
getHideCaret method
Syntax
let configval = config.getHideCaret();
config.hideCaret = configval;
configval = config.hideCaret;
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
getHideScrollbars method
Syntax
let configval = config.getHideScrollbars();
config.hideScrollbars = configval;
configval = config.hideScrollbars;
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
getHostApp method
Syntax
let configval = config.getHostApp();
config.hostApp = configval;
configval = config.hostApp;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getHostOS method
Syntax
let configval = config.getHostOS();
config.hostOS = configval;
configval = config.hostOS;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getIgnoreCaret method
Syntax
let configval = config.getIgnoreCaret();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getIgnoreDisplacements method
Syntax
let configval = config.getIgnoreDisplacements();
Parameters
This method does not take any parameters.
Return value
Type: boolean
getIsDisabled method
Syntax
let configval = config.getIsDisabled();
config.getIsDisabled = configval;
configval = config.getIsDisabled;
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
If true, then all calls to Eyes are ignored, if false then all calls to Eyes work as usual.
getMatchLevel method
Syntax
let configval = config.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](/concepts/best-practices/match-levels-&-regions).
getMatchTimeout method
Syntax
let configval = config.getMatchTimeout();
config.matchTimeout = configval;
configval = config.matchTimeout;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: number
getParentBranchName method
Syntax
let configval = config.getParentBranchName();
config.parentBranchName = configval;
configval = config.parentBranchName;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: string
getProperties method
Syntax
let configval = config.getProperties();
config.properties = configval;
configval = config.properties;
Note that this feature is available as both a method and a property.
Parameters
This method does not take any parameters.
Return value
Type: PropertyData
[]