Skip to main content

Target class

This class provides methods that are used to define the top level target (the entire window, region, element, frame, etc.) for the check method.

Once you create a Target object using one of the factory methods defined by this class, you can configure the checkpoint by calling other methods, chaining them one after the other using the . operator.

The methods in this class are used as part of the check Fluent API to configure and execute checkpoints.

frame method

Syntax

eyes.check(Target.frame(by))
eyes.check(Target.frame(frameNameOrId))
eyes.check(Target.frame(index))
eyes.check(Target.frame(webElement))

Note: This method is a static method.

Parameters

by

Type: By

An element selector which is chosen using the Selenium By class.

frameNameOrId

Type: String

The name or id of the frame element.

index

Type: int

The index of the iframe (as in Selenium By Index).

webElement

Type: WebElement

A reference to the frame element.

Return value

Type: Self

region method

Syntax

eyes.check(Target.region(region))
eyes.check(Target.region(by))
eyes.check(Target.region(webElement))

Note: This method is a static method.

Parameters

region

Type: Region

The region to be checked.

by

Type: By

An element selector which is chosen using the Selenium By class.

webElement

Type: WebElement

An object which defines a region.

Return value

Type: Self

Remarks

The parameter to the method specifies the region to be matched. The enclosing frame(s) are selected by the previous calls in the chain to Target.frame. You may only use this method in the chain if the first method in the chain is Target.frame. You may not call it if the first method in the chain is 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.

window method

Syntax

eyes.check(Target.window())

Note: This method is a static method.

Parameters

This method does not take any parameters.

Return value

Type: Self

accessibility method

Syntax

eyes.check(Applitools::Selenium::Target.window.accessibility(region))
eyes.check(Applitools::Selenium::Target.window.accessibility(element))
eyes.check(Applitools::Selenium::Target.window.accessibility(css_selector))
eyes.check(Applitools::Selenium::Target.window.accessibility(region, type: type))
eyes.check(Applitools::Selenium::Target.window.accessibility(element, type: type))
eyes.check(Applitools::Selenium::Target.window.accessibility(css_selector, type: type))
eyes.check(Applitools::Selenium::Target.window.accessibility(:css, css_selector, type: type))

Parameters

region

Type: Region

An object that defines a rectangular area in the window.

css_selector

Type: CssSelector

A selector that specified one or more elements. The bounding rectangle of each element, defines an accessibility region to be analyzed.

Values

  • CssSelector – The type CssSelector is defined as Text.

type

Type: AccessibilityRegionType

The accessibility type of the region.

element

Type: AnyWebElement

An element bounding rectangle that defines an accessibility region to be analyzed.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

Return value

Type: Self

Remarks

For more information, see The Contrast advisor.

before_render_screenshot_hook method

Syntax

eyes.check(Applitools::Selenium::Target.window.before_render_screenshot_hook('window.scrollTo(0, 350)'))
eyes.check(Applitools::Selenium::Target.window.hooks(beforeCaptureScreenshot: 'window.scrollTo(0, 350)'))

Parameters

hook

Type: Text

A string with legal JavaScript code.

exact method

Syntax

eyes.check(Applitools::Selenium::Target.window.exact(exact: exact_option))

Parameters

exact_option

Values

  • :min_diff_intensity
  • :min_diff_width
  • :min_diff_height
  • :match_threshold

Return value

Type: Self

Remarks

This method sets the default match level for this target. This overrides the hard-coded default and the default match level defined by using match_level.

For a given target you may call only one of the following methods that set a target default match level:

  • match_level
  • strict
  • ignorecolors
  • layout
  • exact

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

floating method

Syntax

target.floating(region_or_element)
target.floating(region_or_element, bounds)
target.floating(region_or_element, bounds, padding)
target.floating(name_or_id)
target.floating(name_or_id, bounds)
target.floating(name_or_id, bounds, padding)
target.floating(css_by, css_selector)
target.floating(css_by, css_selector, bounds)
target.floating(css_by, css_selector, bounds, padding)

Parameters

region_or_element

An object that defines the region or element

Values:

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element
  • Applitools::Region

Syntax:

Applitools::Region.new(10, 10, 20, 20)

name_or_id

Type: String

Defines the element

css_by

Type: SeleniumFinder

Defines the element

css_selector

Type: String

Defines the element

bounds

Type: Applitools::FloatingBounds

Syntax:

Applitools::FloatingBounds.new(10, 10, 10, 10)

padding

Type: Applitools::PaddingBounds

Syntax:

Applitools::PaddingBounds.new(10, 10, 10, 10)

Return value

Type: Self

Remarks

You can call this method multiple times in a given chain; each call defines a different floating region. Floating regions may not overlap each other or other types of regions, such as ignore or match level regions.

frame method

Syntax

eyes.check(Applitools::Selenium::Target.frame(frame_name_or_id))
eyes.check(Applitools::Selenium::Target.frame(element))
eyes.check(Applitools::Selenium::Target.frame(by))

Parameters

frame_name_or_id

Type: String

The name or id of the frame element.

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

by

Type: BySelector

Any legal Selenium By request.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

You can only use this method in the chain if the first method in the chain is frame. You cannot call it if the first method in the chain is window or region. Call this method multiple times to descend a hierarchy of embedded frames.

fully method

Syntax

eyes.check(Applitools::Selenium::Target.window().fully(fully))
eyes.check(Applitools::Selenium::Target.window().fully())

Parameters

fully

Type: bool [Optional : default = True ]

If True, Eyes uses scrolling and stitching to capture the entire page. If False, then only the viewport will be captured. If the method is called without a parameter, then the default is True.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

This method overrides the global default or the most recent value set by the force_full_page_screenshot property.

If stitching is done, then the stitch mode used, Applitools::Selenium::StitchModes::CSS or Applitools::Selenium::StitchModes::SCROLL is determined by the global default or the value set using, stitch_mode. You can use the scroll_root_element property to specify which element should be scrolled to render all of the content of the page.

You may only specify one such element per checkpoint. You may only call this method once in a given target.

ignore method

Syntax

eyes.check(Applitools::Selenium::Target.window().ignore(by))
eyes.check(Applitools::Selenium::Target.window().ignore(element))
eyes.check(Applitools::Selenium::Target.window().ignore(css_selector))
eyes.check(Applitools::Selenium::Target.window().ignore(region))

Parameters

by

Type: BySelector

Any legal Selenium By request

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

css_selector

Type: CssSelector

Any legal CSS selector, for example .myClass

Values

  • CssSelector – The type CssSelector is defined as: Text.

region

Type: Applitools::Region

An object that defines a rectangular area in the window.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

You may call this method multiple times in a given chain.

Ignore regions should not overlap each other or other types of regions such as floating or match level regions.

ignore_caret method

Syntax

eyes.check(Applitools::Selenium::Target.window().ignore_caret(ignore))
eyes.check(Applitools::Selenium::Target.window().ignore_caret)

Parameters

ignore

Type: bool [Optional : default = True ]

If True, Eyes will detect artifacts caused by a blinking cursor and will not report a mismatch for differences caused by these artifacts. If False, then Eyes will not try to detect artifacts caused by blinking cursors. If no parameter is passed then the default value is True, so the cursor artifacts will be ignored.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

You may only call this method once in a given chain. This method overrides the global default setting or the setting chosen explicitly for the current target using ignore_caret property.

ignore_displacements method

Syntax

eyes.check(Applitools::Selenium::Target.window().ignore_displacements(should_ignore))
eyes.check(Applitools::Selenium::Target.window().ignore_displacements)

Parameters

should_ignore

Type: bool [Optional : default = True ]

If True, mismatches due to displaced content will not be displayed in the Test Manager. Otherwise, they will be displayed.

Return value

Type: Self

Remarks

Ignore displacements is only active when using a Match level of STRICT or IGNORECOLORS

layout method

Syntax

eyes.check(Applitools::Selenium::Target.window().layout(by))
eyes.check(Applitools::Selenium::Target.window().layout(element))
eyes.check(Applitools::Selenium::Target.window().layout(css_selector))
eyes.check(Applitools::Selenium::Target.window().layout(region))

Parameters

by

Type: BySelector

Any legal Selenium By reques

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

css_selector

Type: CssSelector

Any legal CSS selector, for example .myClass

Values

  • CssSelector - The type CssSelector is defined as Text.

region

Type: Applitools::Region

An object that defines a rectangular area in the window.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

The parameters in this method define a match level for this region, overriding the defaults set for the target, set by match_level and the hardcoded default match level.

The region matchlevel methods strict(regions) or layout(regions) should not overlap each other. If they overlap, or regions are defined using the Test Manager then the results will be undefined.

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.

match_level method

Syntax

eyes.check(Applitools::Selenium::Target.window().match_level(match_level))

Parameters

match_level

Type: MatchLevel

Available match level values are:

  • Applitools::MatchLevel::NONE
  • Applitools::MatchLevel::LAYOUT
  • Applitools::MatchLevel::IGNORE_COLORS
  • Applitools::MatchLevel::STRICT
  • Applitools::MatchLevel::EXACT

For a description of these match levels and the different ways to apply them to tests, checkpoints, and regions, see Eyes match levels.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

The value provided here overrides the default match level, or the global value set for this target using Eyes.match_level or match_level. You may only call this method once in a given chain. If you call this method, then you can't call the other match level methods, strict, layout, and exact.

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.

region method

Syntax

eyes.check(Applitools::Selenium::Target.region(region))
eyes.check(Applitools::Selenium::Target.region(css_selector))
eyes.check(Applitools::Selenium::Target.region(element))
eyes.check(Applitools::Selenium::Target.region(by))

Parameters

region

Type: Region

An object that defines the region.

css_selector

Type: CssSelector

Any legal CSS selector, for example .myClass

Values

  • CssSelector - The type CssSelector is defined as Text.

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

by

Type: BySelector

Any legal Selenium By request

Return value

Type: Self

Remarks

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 may only use this method in the chain if the first method in the chain is Target.frame. You may not call it if the first method in the chain is 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.

scroll_root_element method

Syntax

eyes.check(Applitools::Selenium::Target.window.scroll_root_element(element))
eyes.check(Applitools::Selenium::Target.window.scroll_root_element(selector))
eyes.check(Applitools::Selenium::Target.window.scroll_root_element(by))

Parameters

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

selector

Type: CssSelector

A CSS selector to the element that should be scrolled.

Values

  • CssSelector - The type CssSelector is defined as Text.

by

Type: BySelector

A By Locator to the element that should be scrolled.

Values

  • BySelector - The type BySelector is defined as: List[SeleniumBy,Text].

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

send_dom method

Syntax

eyes.check(Applitools::Selenium::Target.window.send_dom(senddom))
eyes.check(Applitools::Selenium::Target.window.send_dom())

Parameters

senddom

Type: bool [Optional : default = True ]

If True, send DOM information for this checkpoint even if sending DOM is disabled globally.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

strict method

Syntax

eyes.check(Applitools::Selenium::Target.window.strict(by))
eyes.check(Applitools::Selenium::Target.window.strict(element))
eyes.check(Applitools::Selenium::Target.window.strict(css_selector))
eyes.check(Applitools::Selenium::Target.window.strict(region))

Parameters

by

Type: BySelector

Any legal Selenium By request

element

Type: AnyWebElement

The element object of the frame.

Values

  • Selenium::WebDriver::Element
  • Applitools::Selenium::Element

css_selector

Type: CssSelector

Any legal CSS selector, for example .myClass

Values

  • CssSelector - The type CssSelector is defined as Text.

region

Type: Applitools::Region

An object that defines a rectangular area in the window.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

The value provided here overrides the default match level, or the global value set for this target using Eyes.match_level or match_level. You may only call this method once in a given chain. If you call this method, then you can't call the other match level methods, strict, layout, and exact.

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.

timeout method

Syntax

eyes.check(Applitools::Selenium::Target.window.timeout(timeout))

Parameters

timeout

Type: int

The timeout to use in milliseconds.

Return value

Type: Self

The value returned is the object that called the method. You can use it to call other methods supported by the object class.

Remarks

You may only call this method once in a given chain. The timeout value provided here overrides the default value or the value set by match_timeout for the current target. Passing this method a value of zero disables the timeout mechanism.

variation_group_id method

Syntax

eyes.check(Applitools::Selenium::Target.window.variation_group_id(variation_group_id))

Parameters

variation_group_id

Type: Text

The value of the variation group ID to be set.

Return value

Type: Self

visual_grid_options method

Syntax

eyes.check(Applitools::Selenium::Target.window.visual_grid_options(options))

Parameters

options

Type: VisualGridOption

One or more options for configuring the Ultrafast Grid.

Return value

Type: SeleniumCheckSettings

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 visual_grid_options

You can override the global value for a given checkpoint using the property visual_grid_options.