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

Match level

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

The following match levels are available:

  • Strict - (Default) Detects changes in text, font, color, graphics, and position of elements. It aims to detect differences that are visible to the human eye while ignoring differences in pixel values that are platform dependent due to the rendering software and hardware.

  • Layout - Identifies changes in various page elements, such as text, images, buttons, and columns, and verifies that the relative positions of these elements are consistent. This match level can detect elements that have appeared, disappeared, or moved. With this match level, Eyes ignores differences in the actual content text and graphics, color, and other style changes. This level is useful for pages with dynamic content, language localization, and cross-environment testing where a single baseline is used for multiple execution environments.

  • Ignore colors - Similar to the strict match level but ignores changes in colors. It is effective when your content is static but the color varies, for example if there are buttons or screen elements that can appear in a variety of colors.

  • Exact - Pixel-to-pixel comparison of the checkpoint and baseline images. It is sensitive to differences such as rendering anomalies that are not visible to the human eye. It is not recommended for ordinary verification purposes.

  • Dynamic - Recognizes defined text patterns such as a date, email address, or URL. For details, see Dynamic text match level

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

The default match level is Strict.

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

eyes.matchLevel = .layout

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())
eyes.check(withTag: "Viewport", andSettings: Target.window().dynamic())

Full page screenshot

By default the screenshot only includes the viewport. To scroll to the bottom of the page for the screenshot, use the fully method:

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

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 selected by the previous calls in the chain to Target.frame. 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. You may only call this method once in a given 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

The test will not report any mismatches in an ignore region. This is useful for areas on the screen whose content is different on every run, such as a time of day field.

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

Region match levels

You can set the following match levels for a region:

  • 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.
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

The number of milliseconds to wait before taking 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. If you want to crop the status bar, set the statusBarExists method to true:

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

Timeout

Defines the timeout to use (in seconds) when taking or comparing a screenshot.

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

Ignore caret

If true, the blinking caret will be ignored in the screenshot.

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

Ignore displacement

If true, images that have moved within the page will be ignored.

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

Stitch mode

Determines how full page screenshots should be stitched together. Default is scroll, if this does not produce the expected result, the alternative is resize which uses 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

Determines how XCUI elements should be handled

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)