Eyes constructor
This class provides the main methods used to execute tests and checkpoints.
Import statement
require 'eyes_selenium'
Syntax
eyes.configure do |conf|
# conf.batch = $run_batch
conf.api_key = ENV['APPLITOOLS_API_KEY']
conf.branch_name = branch_name
conf.parent_branch_name = 'master'
conf.save_new_tests = false
conf.hide_caret = true
end
eyes.match_timeout = 0 unless is_visual_grid
Methods
accessibility_validation method
Syntax
eyes.accessibility_validation(
Applitools::AccessibilitySettings.new(
Applitools::AccessibilityLevel::AA, Applitools::AccessibilityVersion::WCAG_2_0
))
This feature is available as both a method and a property.
Parameters
level
Type:
AccessibilityLevel
The required accessibility level. These values represent accessibility levels as defined by WCAG 2.
- AA – The AA level as defined by WCAG 2.
- AAA – The AAA level as defined by WCAG 2.
guidelinesVersion
Type:
AccessibilitySettings
Defines which version of the accessibility standard is used when verifying accessibility.
- WCAG_2_0 – Version 2.0 of the WCAG specification
- WCAG_2_1 – Version 2.1 of the WCAG specification
A value of
None
will disable accessibility checking.
For more information about the Contrast advisor feature see Contrast advisor.
add_property method
Syntax
eyes.add_property(name, value)
Parameters
name
Type: Text
The name of the property.
value
Type: Text
The value associated with the name.
Remarks
- Set multiple properties by calling
Eyes.add_property
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.add_property
.
set_proxy method
Syntax
config.set_proxy('http://localhost:8000')
Parameters
proxy
Type:
ProxySettings
[Optional]An object created from the
ProxySettings
class that contains the user name, password, URI and port.
Return value
Type: Self
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.
Properties
agent_id property
Syntax
eyes.agent_id='custom-agent-id'
Parameters
agent_id
Type: Text
The agent id to be configured.
api_key property
Syntax
eyes.api_key = 'APPLITOOLS_API_KEY'
Parameters
api_key
Type: Text
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.
app_name property
Syntax
eyes.app_name = 'app_name'
Parameters
app_name
Type: Text
The application name to be configured for the test.
Remarks
This property must be set 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 None, then the value set here will be used.
baseline_branch_name property
Syntax
eyes.baseline_branch_name='baseline_branch_name'
Parameters
baseline_branch_name
Type: Text
The baseline branch name to be configured.
baseline_env_name property
Syntax
eyes.baseline_env_name='baseline_env_name'
Parameters
baseline_env_name
Type: Text
The name of the baseline environment.
batch property
Syntax
eyes.batch = Applitools::BatchInfo.new('batch_name')
Parameters
batch
Type:
BatchInfo
An object that defines the batch configuration.
branch_name property
Syntax
eyes.branch_name = 'branch_name'
Parameters
branch_name
Type: Text
The branch name to be used by the configuration.
disabled property
Syntax
eyes.disabled = true
Type: bool
If True
, all method calls to the SDK are ignored. Otherwise, all methods work as usual.
force_full_page_screenshot property
Syntax
eyes.force_full_page_screenshot = true
Parameters
force_full_page_screenshot
Type: bool
If
True
, Eyes will do scrolling and stitching if necessary. IfFalse
, then the result is browser dependent.
hide_caret property
Syntax
eyes.hide_caret = true
Parameters
hide_caret
Type: bool
If
True
, then the cursor will be hidden before the image is captured.
hide_scrollbars property
Syntax
eyes.hide_scrollbars = true
Parameters
hide_scrollbars
Type: bool
If
True
, hide scrollbars.
host_app property
Syntax
eyes.host_app = 'app'
Parameters
host_app
Type: Text
The value to be used for the Host App property.
host_os property
Syntax
eyes.host_os = host_os
Parameters
host_os
Type: Text
The value to be used for the Host OS Property.
ignore_caret property
Syntax
eyes.ignore_caret = true
Parameters
ignore_caret
Type: bool
Remarks
We recommend using set_hide_caret
since this eliminates cursor related artifacts instead of detecting and ignoring them.
ignore_displacements property
Syntax
eyes.ignore_displacements = true
Parameters
ignore_displacements
Type: bool
If
True
, mismatches due to displaced content will not be displayed in the Test Manager. Otherwise, they will be displayed.
Remarks
Ignore displacements is only active when using a Match level of STRICT
or IGNORECOLORS
.
match_level property
Syntax
eyes.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 full description of the affect of each match levels and the different ways to apply them to tests, checkpoints and regions, see How to use Eyes match levels.
match_timeout property
Syntax
eyes.match_timeout = 0
Parameters
match_timeout
Type: int
The timeout to set in milliseconds.
Remarks
You can override the default timeout set by this property for a specific set checkpoint by passing a timeout to one of the check_XXXX
methods that support a timeout parameter, e.g. check_window
. You can also override the timeout for a specific test using the check fluent timeout method
.
parent_branch_name property
Syntax
eyes.parent_branch_name = 'master'
Parameters
parent_branch_name
Type: Text
The parent branch name to be configured.
properties property
Syntax
eyes.properties = [{ 'name' => 'custom_prop', 'value' => 'custom value' }]
Remarks
- Set multiple properties by calling
Eyes.add_property
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.add_property
.
save_diffs property
Syntax
eyes.save_diffs = false
Parameters
save_diffs
Type: bool
Set to
True
to configure Save Diffs functionality.
save_new_tests property
Syntax
eyes.save_new_tests = false
Parameters
save_new_tests
Type: bool
If
False
, the user will need to save the baseline explicitly in the Test Manager for new tests to be saved to the baseline. IfTrue
, Eyes will automatically create a baseline for tests with a status of 'new' (the default behavior).
send_dom property
Syntax
eyes.send_dom = false
Parameters
send_dom
Type: bool
If
True
, DOM information will be sent.
Remarks
Sending DOM information is enabled by default, so use this property only if you have to disable it.
server_url property
Syntax
eyes.server_url = 'server_url'
Parameters
server_url
Type: Text
The URL of the Eyes server. Pass a value of
None
to use the default cloud server.
stitch_mode property
Defines the mechanism used to offset sub-images when generating a full page image by stitching together multiple sub-images. If the width or height of a page being checked is larger than the viewport, and the entire page is being checked, then the full page image is generated by capturing multiple sub-images on the page at different offsets and stitching these image together. This enumerated value is used to define the type of mechanism to be used to offset the image before capturing each sub-image. In general, use of CSS is recommended, although the default is SCROLL. On pages with complex CSS or scrolling, if one method causes issues, then using the other method may avoid them.
Syntax
eyes.stitch_mode = Applitools::Selenium::StitchModes::CSS
Parameters
stitch_mode
Type:
StitchMode
The stitch mode to use.
Values
Applitools::Selenium::StitchModes::CSS
Applitools::Selenium::StitchModes::SCROLL
stitching_overlap property
Syntax
eyes.stitching_overlap = 0
Parameters
stitching_overlap
Type: int
The width of the stitch overlap in pixels.
test_name property
Syntax
eyes.test_name = 'test_name'
Parameters
test_name
Type: Text
The test name to be configured for the test.
viewport_size property
Syntax
eyes.viewport_size = Applitools::RectangleSize.new(600, 600)
Parameters
viewport_size
Type: ViewPort
An object that defines the width and height of the test browser viewport in pixels.
Values
Applitools::RectangleSize
visual_grid_options property
Syntax
eyes.visual_grid_options = {polyfillAdoptedStyleSheets: true}
Parameters
options
Type:
VisualGridOption
One or more configuration options for the Ultrafast Grid.
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.
wait_before_screenshots property
Syntax
eyes.wait_before_screenshots = 1
Parameters
wait_before_screenshots
Type: int
The time to wait in milliseconds. Passing a value of less than or equal to zero will cause the default value to be used.