Skip to main content

Check settings

checkSettings generates a screenshot of the current page and adds it to the Applitools Eyes test.

The methods in this class are used as part of the check(withTag:andSettings:) Fluent API to configure and execute checkpoints. To use these methods, first create a target object using a method from the Target class, then call one or more of the methods in this class on the returned object, using a series of nested calls.

Import statement

import EyesXCUI

Full page screenshot

By default, the screenshot scrolls to the bottom of the page to capture the full content.

eyes.check(withTag: "Full-page screenshot", andSettings: Target.window())

Viewport screenshot

To capture only the viewport without scrolling, set the fully() method to false.

eyes.check(withTag: "Viewport screenshot", andSettings: Target.window().fully(false))

To change the default behavior for all screenshots:

let configuration = Configuration()
configuration.forceFullPageScreenshot = false
eyes.configuration = configuration

Region screenshot

To take an element screenshot, you can specify either a UI element or a rectangle.

The parameter to the method specifies the region to be matched. The enclosing frames are determined by prior calls to Target.frame in the chain. You can only use this method in the chain if the first method in the chain is Target.frame, not Target.window or Target.region.

To match a region within a window, use the method Target.region as the first method in the Target chain. This method can only be called once in a chain.

Example

eyes.check(withTag: "Region by element", andSettings: Target.element(application.tables.element(boundBy:0))

You can also specify the absolute coordinates for a region:

eyes.check(withTag: "Region by coordinates", andSettings: Target.region(Region(
left: 10,
top: 20,
width: 200,
height: 80
)))

For all the above options, you can specify .fully() to take the entire content of an element that can be scrolled.

Ignore regions

Ignored regions are excluded from mismatch detection during the test. This is useful for dynamic areas of the screen, such as timestamps or session IDs, which change with each run.

eyes.check(withTag: "Ignored regions", andSettings: Target.window().ignore([region1, region2, ...]))

Floating regions

In a floating region, the position of a region can move without reporting a mismatch.

eyes.check(withTag: "Floating regions", andSettings: Target.window().floating([region1, region2, ...]))

Match level

The match level determines how Eyes compares the checkpoint image with the baseline image.

The following match levels are available:

  • Strict: Detect any mismatch visible to the human eye.
  • Layout: Check only the layout and ignore actual text and graphics.
  • Content: Similar to the strict match level but ignores changes in colors.
  • Exact: Pixel-to-pixel comparison of the checkpoint and baseline images (not recommended).

For more information, see How to use Eyes match levels.

The default match level is Strict.

To change the match level for a single checkpoint:

eyes.check(withTag: "Viewport", andSettings: Target.window().layout())
eyes.check(withTag: "Viewport", andSettings: Target.window().strict())
eyes.check(withTag: "Viewport", andSettings: Target.window().content())
eyes.check(withTag: "Viewport", andSettings: Target.window().exact())

To change the match level for the rest of the execution:

eyes.matchLevel = .layout

Region match levels

You can set the following match levels for a region:

eyes.check(withTag: "screenshot with strict regions", andSettings: Target.window().strict([region1, region2, ...]))
eyes.check(withTag: "screenshot with layout regions", andSettings: Target.window().layout([region1, region2, ...]))
eyes.check(withTag: "screenshot with content regions", andSettings: Target.window().content([region1, region2, ...]))

For more information, see How to use Eyes match levels in the Eyes Knowledge Center.

Wait before capture

Defines the wait time (in milliseconds) before capturing a screenshot.

eyes.check(withTag: "screenshot waiting before capture", andSettings: Target.window().wait(beforeCapture: 5))

Cropping the status bar

By default, the status bar is included in the screenshot. To exclude the status bar from the screenshot, set the statusBarExists method to true:

eyes.check(withTag: "Without status bar", andSettings: Target.window().statusBarExists(true))

Timeout

Sets the timeout duration (in seconds) for capturing or comparing a screenshot.

eyes.check(withTag: "screenshot with timeout", andSettings: Target.window().timeout(inSeconds: 5))

Ignore caret

When set to true, the blinking caret is excluded from the screenshot.

eyes.check(withTag: "screenshot ignoring caret", andSettings: Target.window().ignoreCaret(true))

Ignore displacement

When set to true, image movements within the page are ignored.

eyes.check(withTag: "screenshot ignoring displacements", andSettings: Target.window().ignoreDisplacements(true))

Stitch mode

Defines the stitching method for full-page screenshots. The default method is scroll. If it does not produce the desired result, use resize, which applies a different algorithm.

eyes.check(withTag: "full page by scroll", andSettings: Target.window().fully().stitchMode(.scroll))
eyes.check(withTag: "full page by resize", andSettings: Target.window().fully().stitchMode(.resize))

XCUI elements

Defines the handling of XCUI elements.

let element = application.tables.staticTexts["[H] Hydrogen (1)"]
eyes.check(withTag: "single element", andSettings: Target.element(element))

let ignoredElement = application.tables.staticTexts["[He] Helium (2)"]
let contentElement = application.tables.staticTexts["[Li] Lithium (3)"]
let strictElement = application.tables.staticTexts["[Be] Beryllium (4)"]
let layoutElement = application.tables.staticTexts["[B] Boron (5)"]
let floatingElement = application.tables.staticTexts["[C] Carbon (6)"]

let settings = Target.window()
.ignoreXCUIElements([ignoredElement])
.contentXCUIElements([contentElement])
.strictXCUIElements([strictElement])
.layoutXCUIElements([layoutElement])
.floatingXCUIElement(floatingElement)

eyes.check(withTag: "elements", andSettings: settings)