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 EyesImages

Custom image

Validate an image created by your own means, using Target.image().

let myImage = UIImage(named: "pre-rendered image")
eyes.check(withTag: "Custom image", andSettings: Target.image(myImage))

Full-page screenshot

Validate a screenshot taken by the SDK, using Target.window().

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

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

The window() target requires the test functions to be annotated with @MainActor, and marked as async throws.

Viewport screenshot

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

try await 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

Device target

By default, Target.window() takes a screenshot of the device (or simulator) on which the test is executed. When running the same test from a variety of devices or simulators, the images generated will be of different sizes. To standardize all images to a single size, regardless of the actual execution device, add a target device to the Eyes configuration:

let configuration = Configuration()
configuration.addMultiDeviceTarget(IosMultiDeviceTarget.iPhone12())
eyes.configuration = configuration

Wait before capture

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

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

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.

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

Regions are defined either by hardcoded rectangles (Region(rect:)), or by direct references to UIView objects from your application.

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, ...]))

Regions are defined either by hardcoded rectangles (Region(rect:)), or by direct references to UIView objects from your application.