Class: Applitools::Eyes
- Inherits:
-
Object
- Object
- Applitools::Eyes
- Extended by:
- Forwardable
- Defined in:
- lib/applitools/eyes.rb
Constant Summary collapse
- FAILURE_REPORTS =
{ immediate: 'Immediate', on_close: 'OnClose' }.freeze
- MATCH_LEVEL =
{ none: 'None', layout: 'Layout', layout2: 'Layout2', content: 'Content', strict: 'Strict', exact: 'Exact' }.freeze
- DEFAULT_MATCH_TIMEOUT =
Seconds
2.0- DEFAULT_WAIT_BEFORE_SCREENSHOTS =
noinspection RubyConstantNamingConvention
0.1- BASE_AGENT_ID =
Seconds
('eyes.selenium.ruby/' + Applitools::VERSION).freeze
- ANDROID =
'Android'.freeze
- IOS =
'iOS'.freeze
Instance Attribute Summary collapse
-
#agent_id ⇒ Object
Returns the value of attribute agent_id.
-
#app_name ⇒ Object
readonly
Attributes:.
-
#baseline_name ⇒ Object
Returns the value of attribute baseline_name.
-
#batch ⇒ Object
Returns the value of attribute batch.
-
#branch_name ⇒ Object
Returns the value of attribute branch_name.
-
#driver ⇒ Object
readonly
Attributes:.
-
#failure_reports ⇒ Object
Returns the value of attribute failure_reports.
-
#force_fullpage_screenshot ⇒ Object
Returns the value of attribute force_fullpage_screenshot.
-
#hide_scrollbars ⇒ Object
Returns the value of attribute hide_scrollbars.
-
#host_app ⇒ Object
Returns the value of attribute host_app.
-
#host_os ⇒ Object
Returns the value of attribute host_os.
-
#is_disabled ⇒ Object
Returns the value of attribute is_disabled.
-
#is_open ⇒ Object
readonly
Attributes:.
-
#match_level ⇒ Object
Returns the value of attribute match_level.
-
#match_timeout ⇒ Object
Returns the value of attribute match_timeout.
-
#parent_branch_name ⇒ Object
Returns the value of attribute parent_branch_name.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#save_failed_tests ⇒ Object
Returns the value of attribute save_failed_tests.
-
#save_new_tests ⇒ Object
Returns the value of attribute save_new_tests.
-
#scale_ratio ⇒ Object
Returns the value of attribute scale_ratio.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#test_name ⇒ Object
readonly
Attributes:.
-
#use_css_transition ⇒ Object
Returns the value of attribute use_css_transition.
-
#user_inputs ⇒ Object
Returns the value of attribute user_inputs.
-
#viewport_size ⇒ Object
readonly
Attributes:.
-
#wait_before_screenshots ⇒ Object
Returns the value of attribute wait_before_screenshots.
Instance Method Summary collapse
- #abort_if_not_closed ⇒ Object
- #check_region(how, what, tag = nil, specific_timeout = -1)) ⇒ Object
- #check_window(tag = nil, specific_timeout = -1)) ⇒ Object
- #clear_user_inputs ⇒ Object
- #close(raise_ex = true) ⇒ Object
- #full_agent_id ⇒ Object
-
#initialize(options = {}) ⇒ Eyes
constructor
A new instance of Eyes.
- #open(options = {}) ⇒ Object
- #open? ⇒ Boolean
-
#test(options = {}, &_block) ⇒ Object
Use this method to perform seamless testing with selenium through eyes driver.
- #title ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Eyes
Returns a new instance of Eyes.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/applitools/eyes.rb', line 104 def initialize( = {}) @is_disabled = false return if disabled? @api_key = nil @user_inputs = [] Applitools::Base::ServerConnector.server_url = [:server_url] @match_timeout = DEFAULT_MATCH_TIMEOUT @match_level = Applitools::Eyes::MATCH_LEVEL[:exact] @failure_reports = Applitools::Eyes::FAILURE_REPORTS[:on_close] @save_new_tests = true @save_failed_tests = false @dont_get_title = false @force_fullpage_screenshot = false @hide_scrollbars = false @use_css_transition = false @wait_before_screenshots = DEFAULT_WAIT_BEFORE_SCREENSHOTS end |
Instance Attribute Details
#agent_id ⇒ Object
Returns the value of attribute agent_id.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def agent_id @agent_id end |
#app_name ⇒ Object (readonly)
Attributes:
app_name-
StringThe application name which was provided as an argument toopen. test_name-
StringThe test name which was provided as an argument toopen. is_open-
booleanIs there an open session. viewport_size-
HashThe viewport size which was provided as an argument toopen. Should includewidth
and +height+.
driver-
Applitools::Selenium::DriverThe driver instance wrapping the driver which was provided as an argument
to +open+.
api_key-
StringThe user’s API key. match_timeout-
FloatThe default timeout for check_XXXX operations. (Seconds) batch-
BatchInfoThe current tests grouping, if any. host_os-
StringA string identifying the OS running the AUT. Set this if you wish to override Eyes’ automatic
inference.
host_app-
StringA string identifying the container application running the AUT (e.g., Firefox). Set this if
you wish to override Eyes' automatic inference.
branch_name-
StringIf set, names the branch in which the test should run. parent_branch_name-
StringIf set, names the parent branch of the branch in which the test should run. user_inputs-
Applitools::Base::MouseTrigger/Applitools::Selenium::KeyboardTriggerMouse/Keyboard events which
happened after the last visual validation.
save_new_tests-
booleanWhether or not new tests should be automatically accepted as baseline. save_failed_tests-
booleanWhether or not failed tests should be automatically accepted as baseline. match_level-
StringThe default match level for the entire session. SeeApplitools::Eyes::MATCH_LEVEL. baseline_name-
StringA string identifying the baseline which the test will be compared against. Set this if
you wish to override Eyes' automatic baseline inference.
is_disabled-
booleanSet totrueif you wish to disable Eyes without deleting code (Eyes’ methods act as a
mock, and will do nothing).
server_url-
StringThe Eyes’ server. Set this if you wish to override the default Eyes server URL. agent_id-
StringAn optional string identifying the current library using the SDK. log_handler-
LoggerThe logger to which Eyes will send info/debug messages. failure_reports-
StringWhether the current test will report mismatches immediately or when it is finished.
See +Applitools::Eyes::FAILURE_REPORTS+.
rotation-
Integer|nilThe degrees by which to rotate the screenshots received from the driver. Set this to
override Eyes' automatic rotation inference. Positive values = clockwise rotation, negative
values = counter-clockwise, 0 = force no rotation, +nil+ = use Eyes' automatic rotation inference.
scale_ratio-
Float|nilThe ratio by which to scale the screenshots received from the driver. Set this to
override Eyes' automatic scaling inference. Values must be >=0 or +nil+. 1 = Don't scale, +nil+ = use Eyes'
automatic scaling inference.
force_fullpage_screenshot-
booleanWhether or not to force fullpage screenshot taking, if the browser doesn’t
support it explicitly.
hide_scrollbars-
booleanWhether or not hide scrollbars. use_css_transition-
booleanWhether or not to perform CSS transition. wait_before_screenshot-
IntegerThe number of milliseconds to wait before each screenshot. Use -1 to reset to
the default value.
75 76 77 |
# File 'lib/applitools/eyes.rb', line 75 def app_name @app_name end |
#baseline_name ⇒ Object
Returns the value of attribute baseline_name.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def baseline_name @baseline_name end |
#batch ⇒ Object
Returns the value of attribute batch.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def batch @batch end |
#branch_name ⇒ Object
Returns the value of attribute branch_name.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def branch_name @branch_name end |
#driver ⇒ Object (readonly)
Attributes:
app_name-
StringThe application name which was provided as an argument toopen. test_name-
StringThe test name which was provided as an argument toopen. is_open-
booleanIs there an open session. viewport_size-
HashThe viewport size which was provided as an argument toopen. Should includewidth
and +height+.
driver-
Applitools::Selenium::DriverThe driver instance wrapping the driver which was provided as an argument
to +open+.
api_key-
StringThe user’s API key. match_timeout-
FloatThe default timeout for check_XXXX operations. (Seconds) batch-
BatchInfoThe current tests grouping, if any. host_os-
StringA string identifying the OS running the AUT. Set this if you wish to override Eyes’ automatic
inference.
host_app-
StringA string identifying the container application running the AUT (e.g., Firefox). Set this if
you wish to override Eyes' automatic inference.
branch_name-
StringIf set, names the branch in which the test should run. parent_branch_name-
StringIf set, names the parent branch of the branch in which the test should run. user_inputs-
Applitools::Base::MouseTrigger/Applitools::Selenium::KeyboardTriggerMouse/Keyboard events which
happened after the last visual validation.
save_new_tests-
booleanWhether or not new tests should be automatically accepted as baseline. save_failed_tests-
booleanWhether or not failed tests should be automatically accepted as baseline. match_level-
StringThe default match level for the entire session. SeeApplitools::Eyes::MATCH_LEVEL. baseline_name-
StringA string identifying the baseline which the test will be compared against. Set this if
you wish to override Eyes' automatic baseline inference.
is_disabled-
booleanSet totrueif you wish to disable Eyes without deleting code (Eyes’ methods act as a
mock, and will do nothing).
server_url-
StringThe Eyes’ server. Set this if you wish to override the default Eyes server URL. agent_id-
StringAn optional string identifying the current library using the SDK. log_handler-
LoggerThe logger to which Eyes will send info/debug messages. failure_reports-
StringWhether the current test will report mismatches immediately or when it is finished.
See +Applitools::Eyes::FAILURE_REPORTS+.
rotation-
Integer|nilThe degrees by which to rotate the screenshots received from the driver. Set this to
override Eyes' automatic rotation inference. Positive values = clockwise rotation, negative
values = counter-clockwise, 0 = force no rotation, +nil+ = use Eyes' automatic rotation inference.
scale_ratio-
Float|nilThe ratio by which to scale the screenshots received from the driver. Set this to
override Eyes' automatic scaling inference. Values must be >=0 or +nil+. 1 = Don't scale, +nil+ = use Eyes'
automatic scaling inference.
force_fullpage_screenshot-
booleanWhether or not to force fullpage screenshot taking, if the browser doesn’t
support it explicitly.
hide_scrollbars-
booleanWhether or not hide scrollbars. use_css_transition-
booleanWhether or not to perform CSS transition. wait_before_screenshot-
IntegerThe number of milliseconds to wait before each screenshot. Use -1 to reset to
the default value.
75 76 77 |
# File 'lib/applitools/eyes.rb', line 75 def driver @driver end |
#failure_reports ⇒ Object
Returns the value of attribute failure_reports.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def failure_reports @failure_reports end |
#force_fullpage_screenshot ⇒ Object
Returns the value of attribute force_fullpage_screenshot.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def force_fullpage_screenshot @force_fullpage_screenshot end |
#hide_scrollbars ⇒ Object
Returns the value of attribute hide_scrollbars.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def @hide_scrollbars end |
#host_app ⇒ Object
Returns the value of attribute host_app.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def host_app @host_app end |
#host_os ⇒ Object
Returns the value of attribute host_os.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def host_os @host_os end |
#is_disabled ⇒ Object
Returns the value of attribute is_disabled.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def is_disabled @is_disabled end |
#is_open ⇒ Object (readonly)
Attributes:
app_name-
StringThe application name which was provided as an argument toopen. test_name-
StringThe test name which was provided as an argument toopen. is_open-
booleanIs there an open session. viewport_size-
HashThe viewport size which was provided as an argument toopen. Should includewidth
and +height+.
driver-
Applitools::Selenium::DriverThe driver instance wrapping the driver which was provided as an argument
to +open+.
api_key-
StringThe user’s API key. match_timeout-
FloatThe default timeout for check_XXXX operations. (Seconds) batch-
BatchInfoThe current tests grouping, if any. host_os-
StringA string identifying the OS running the AUT. Set this if you wish to override Eyes’ automatic
inference.
host_app-
StringA string identifying the container application running the AUT (e.g., Firefox). Set this if
you wish to override Eyes' automatic inference.
branch_name-
StringIf set, names the branch in which the test should run. parent_branch_name-
StringIf set, names the parent branch of the branch in which the test should run. user_inputs-
Applitools::Base::MouseTrigger/Applitools::Selenium::KeyboardTriggerMouse/Keyboard events which
happened after the last visual validation.
save_new_tests-
booleanWhether or not new tests should be automatically accepted as baseline. save_failed_tests-
booleanWhether or not failed tests should be automatically accepted as baseline. match_level-
StringThe default match level for the entire session. SeeApplitools::Eyes::MATCH_LEVEL. baseline_name-
StringA string identifying the baseline which the test will be compared against. Set this if
you wish to override Eyes' automatic baseline inference.
is_disabled-
booleanSet totrueif you wish to disable Eyes without deleting code (Eyes’ methods act as a
mock, and will do nothing).
server_url-
StringThe Eyes’ server. Set this if you wish to override the default Eyes server URL. agent_id-
StringAn optional string identifying the current library using the SDK. log_handler-
LoggerThe logger to which Eyes will send info/debug messages. failure_reports-
StringWhether the current test will report mismatches immediately or when it is finished.
See +Applitools::Eyes::FAILURE_REPORTS+.
rotation-
Integer|nilThe degrees by which to rotate the screenshots received from the driver. Set this to
override Eyes' automatic rotation inference. Positive values = clockwise rotation, negative
values = counter-clockwise, 0 = force no rotation, +nil+ = use Eyes' automatic rotation inference.
scale_ratio-
Float|nilThe ratio by which to scale the screenshots received from the driver. Set this to
override Eyes' automatic scaling inference. Values must be >=0 or +nil+. 1 = Don't scale, +nil+ = use Eyes'
automatic scaling inference.
force_fullpage_screenshot-
booleanWhether or not to force fullpage screenshot taking, if the browser doesn’t
support it explicitly.
hide_scrollbars-
booleanWhether or not hide scrollbars. use_css_transition-
booleanWhether or not to perform CSS transition. wait_before_screenshot-
IntegerThe number of milliseconds to wait before each screenshot. Use -1 to reset to
the default value.
75 76 77 |
# File 'lib/applitools/eyes.rb', line 75 def is_open @is_open end |
#match_level ⇒ Object
Returns the value of attribute match_level.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def match_level @match_level end |
#match_timeout ⇒ Object
Returns the value of attribute match_timeout.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def match_timeout @match_timeout end |
#parent_branch_name ⇒ Object
Returns the value of attribute parent_branch_name.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def parent_branch_name @parent_branch_name end |
#rotation ⇒ Object
Returns the value of attribute rotation.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def rotation @rotation end |
#save_failed_tests ⇒ Object
Returns the value of attribute save_failed_tests.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def save_failed_tests @save_failed_tests end |
#save_new_tests ⇒ Object
Returns the value of attribute save_new_tests.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def save_new_tests @save_new_tests end |
#scale_ratio ⇒ Object
Returns the value of attribute scale_ratio.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def scale_ratio @scale_ratio end |
#server_url ⇒ Object
Returns the value of attribute server_url.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def server_url @server_url end |
#test_name ⇒ Object (readonly)
Attributes:
app_name-
StringThe application name which was provided as an argument toopen. test_name-
StringThe test name which was provided as an argument toopen. is_open-
booleanIs there an open session. viewport_size-
HashThe viewport size which was provided as an argument toopen. Should includewidth
and +height+.
driver-
Applitools::Selenium::DriverThe driver instance wrapping the driver which was provided as an argument
to +open+.
api_key-
StringThe user’s API key. match_timeout-
FloatThe default timeout for check_XXXX operations. (Seconds) batch-
BatchInfoThe current tests grouping, if any. host_os-
StringA string identifying the OS running the AUT. Set this if you wish to override Eyes’ automatic
inference.
host_app-
StringA string identifying the container application running the AUT (e.g., Firefox). Set this if
you wish to override Eyes' automatic inference.
branch_name-
StringIf set, names the branch in which the test should run. parent_branch_name-
StringIf set, names the parent branch of the branch in which the test should run. user_inputs-
Applitools::Base::MouseTrigger/Applitools::Selenium::KeyboardTriggerMouse/Keyboard events which
happened after the last visual validation.
save_new_tests-
booleanWhether or not new tests should be automatically accepted as baseline. save_failed_tests-
booleanWhether or not failed tests should be automatically accepted as baseline. match_level-
StringThe default match level for the entire session. SeeApplitools::Eyes::MATCH_LEVEL. baseline_name-
StringA string identifying the baseline which the test will be compared against. Set this if
you wish to override Eyes' automatic baseline inference.
is_disabled-
booleanSet totrueif you wish to disable Eyes without deleting code (Eyes’ methods act as a
mock, and will do nothing).
server_url-
StringThe Eyes’ server. Set this if you wish to override the default Eyes server URL. agent_id-
StringAn optional string identifying the current library using the SDK. log_handler-
LoggerThe logger to which Eyes will send info/debug messages. failure_reports-
StringWhether the current test will report mismatches immediately or when it is finished.
See +Applitools::Eyes::FAILURE_REPORTS+.
rotation-
Integer|nilThe degrees by which to rotate the screenshots received from the driver. Set this to
override Eyes' automatic rotation inference. Positive values = clockwise rotation, negative
values = counter-clockwise, 0 = force no rotation, +nil+ = use Eyes' automatic rotation inference.
scale_ratio-
Float|nilThe ratio by which to scale the screenshots received from the driver. Set this to
override Eyes' automatic scaling inference. Values must be >=0 or +nil+. 1 = Don't scale, +nil+ = use Eyes'
automatic scaling inference.
force_fullpage_screenshot-
booleanWhether or not to force fullpage screenshot taking, if the browser doesn’t
support it explicitly.
hide_scrollbars-
booleanWhether or not hide scrollbars. use_css_transition-
booleanWhether or not to perform CSS transition. wait_before_screenshot-
IntegerThe number of milliseconds to wait before each screenshot. Use -1 to reset to
the default value.
75 76 77 |
# File 'lib/applitools/eyes.rb', line 75 def test_name @test_name end |
#use_css_transition ⇒ Object
Returns the value of attribute use_css_transition.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def use_css_transition @use_css_transition end |
#user_inputs ⇒ Object
Returns the value of attribute user_inputs.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def user_inputs @user_inputs end |
#viewport_size ⇒ Object (readonly)
Attributes:
app_name-
StringThe application name which was provided as an argument toopen. test_name-
StringThe test name which was provided as an argument toopen. is_open-
booleanIs there an open session. viewport_size-
HashThe viewport size which was provided as an argument toopen. Should includewidth
and +height+.
driver-
Applitools::Selenium::DriverThe driver instance wrapping the driver which was provided as an argument
to +open+.
api_key-
StringThe user’s API key. match_timeout-
FloatThe default timeout for check_XXXX operations. (Seconds) batch-
BatchInfoThe current tests grouping, if any. host_os-
StringA string identifying the OS running the AUT. Set this if you wish to override Eyes’ automatic
inference.
host_app-
StringA string identifying the container application running the AUT (e.g., Firefox). Set this if
you wish to override Eyes' automatic inference.
branch_name-
StringIf set, names the branch in which the test should run. parent_branch_name-
StringIf set, names the parent branch of the branch in which the test should run. user_inputs-
Applitools::Base::MouseTrigger/Applitools::Selenium::KeyboardTriggerMouse/Keyboard events which
happened after the last visual validation.
save_new_tests-
booleanWhether or not new tests should be automatically accepted as baseline. save_failed_tests-
booleanWhether or not failed tests should be automatically accepted as baseline. match_level-
StringThe default match level for the entire session. SeeApplitools::Eyes::MATCH_LEVEL. baseline_name-
StringA string identifying the baseline which the test will be compared against. Set this if
you wish to override Eyes' automatic baseline inference.
is_disabled-
booleanSet totrueif you wish to disable Eyes without deleting code (Eyes’ methods act as a
mock, and will do nothing).
server_url-
StringThe Eyes’ server. Set this if you wish to override the default Eyes server URL. agent_id-
StringAn optional string identifying the current library using the SDK. log_handler-
LoggerThe logger to which Eyes will send info/debug messages. failure_reports-
StringWhether the current test will report mismatches immediately or when it is finished.
See +Applitools::Eyes::FAILURE_REPORTS+.
rotation-
Integer|nilThe degrees by which to rotate the screenshots received from the driver. Set this to
override Eyes' automatic rotation inference. Positive values = clockwise rotation, negative
values = counter-clockwise, 0 = force no rotation, +nil+ = use Eyes' automatic rotation inference.
scale_ratio-
Float|nilThe ratio by which to scale the screenshots received from the driver. Set this to
override Eyes' automatic scaling inference. Values must be >=0 or +nil+. 1 = Don't scale, +nil+ = use Eyes'
automatic scaling inference.
force_fullpage_screenshot-
booleanWhether or not to force fullpage screenshot taking, if the browser doesn’t
support it explicitly.
hide_scrollbars-
booleanWhether or not hide scrollbars. use_css_transition-
booleanWhether or not to perform CSS transition. wait_before_screenshot-
IntegerThe number of milliseconds to wait before each screenshot. Use -1 to reset to
the default value.
75 76 77 |
# File 'lib/applitools/eyes.rb', line 75 def @viewport_size end |
#wait_before_screenshots ⇒ Object
Returns the value of attribute wait_before_screenshots.
76 77 78 |
# File 'lib/applitools/eyes.rb', line 76 def wait_before_screenshots @wait_before_screenshots end |
Instance Method Details
#abort_if_not_closed ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/applitools/eyes.rb', line 311 def abort_if_not_closed return if disabled? @is_open = false return unless @session begin Applitools::Base::ServerConnector.stop_session(@session, true, false) rescue => e Applitools::EyesLogger.error "Failed to abort server session: #{e.}!" ensure @session = nil end end |
#check_region(how, what, tag = nil, specific_timeout = -1)) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/applitools/eyes.rb', line 185 def check_region(how, what, tag = nil, specific_timeout = -1) Applitools::EyesLogger.debug 'check_region called' return if disabled? # We have to start the session if it's not started, since we want the viewport size to be set before getting the # element's position and size raise Applitools::EyesError.new('Eyes not open') unless open? unless @session Applitools::EyesLogger.debug 'Starting session...' start_session Applitools::EyesLogger.debug 'Done! Creating match window task...' @match_window_task = Applitools::Selenium::MatchWindowTask.new(self, @session, driver, match_timeout) Applitools::EyesLogger.debug 'Done!' end original_overflow = driver. if begin if how == :element Applitools::EyesLogger.debug 'Element given as an argument...' raise Applitools::EyesError.new('Element does not exist') if what.nil? element_to_check = what else Applitools::EyesLogger.debug 'Finding element...' element_to_check = driver.find_element(how, what) end Applitools::EyesLogger.debug 'Done! Getting element location...' location = element_to_check.location Applitools::EyesLogger.debug 'Done! Getting element size...' size = element_to_check.size raise Applitools::EyesError.new("Invalid region size: #{size}") if size.width <= 0 || size.height <= 0 Applitools::EyesLogger.debug 'Done! Creating region...' region = Applitools::Base::Region.new(location.x, location.y, size.width, size.height) Applitools::EyesLogger.debug "Done! Checking region... #{region}" check_region_(region, tag, specific_timeout) Applitools::EyesLogger.debug 'Done!' ensure driver.set_overflow(original_overflow) if end end |
#check_window(tag = nil, specific_timeout = -1)) ⇒ Object
227 228 229 230 231 232 233 234 |
# File 'lib/applitools/eyes.rb', line 227 def check_window(tag = nil, specific_timeout = -1) original_overflow = driver. if begin check_region_(Applitools::Base::Region::EMPTY, tag, specific_timeout) ensure driver.set_overflow(original_overflow) if end end |
#clear_user_inputs ⇒ Object
181 182 183 |
# File 'lib/applitools/eyes.rb', line 181 def clear_user_inputs user_inputs.clear end |
#close(raise_ex = true) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/applitools/eyes.rb', line 236 def close(raise_ex = true) return if disabled? @is_open = false # If there's no running session, the test was never started (never reached check_window). unless @session Applitools::EyesLogger.debug 'Server session was not started' Applitools::EyesLogger.info '--- Empty test ended.' return Applitools::Base::TestResults.new end session_results_url = @session.url new_session = @session.new_session? Applitools::EyesLogger.debug 'Ending server session...' save = (new_session && save_new_tests) || (!new_session && save_failed_tests) results = Applitools::Base::ServerConnector.stop_session(@session, false, save) results.is_new = new_session results.url = session_results_url Applitools::EyesLogger.debug "Results: #{results}" @session = nil if new_session instructions = "Please approve the new baseline at #{session_results_url}" Applitools::EyesLogger.info "--- New test ended. #{instructions}" if raise_ex = "'#{@session_start_info.scenario_id_or_name}' of '#{@session_start_info.app_id_or_name}'. "\ "#{instructions}" raise Applitools::NewTestError.new(, results) end return results end unless results.passed? # Test failed Applitools::EyesLogger.info "--- Failed test ended. See details at #{session_results_url}" if raise_ex = "'#{@session_start_info.scenario_id_or_name}' of '#{@session_start_info.app_id_or_name}'. see "\ "details at #{session_results_url}" raise Applitools::TestFailedError.new(, results) end return results end # Test passed Applitools::EyesLogger.info "--- Test passed. See details at #{session_results_url}" results end |
#full_agent_id ⇒ Object
88 89 90 |
# File 'lib/applitools/eyes.rb', line 88 def full_agent_id @full_agent_id ||= agent_id.nil? ? BASE_AGENT_ID : "#{agent_id} [#{BASE_AGENT_ID}]" end |
#open(options = {}) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/applitools/eyes.rb', line 126 def open( = {}) @driver = get_driver() return driver if disabled? if api_key.nil? raise Applitools::EyesError.new('API key not set! Log in to https://applitools.com to obtain your API Key and '\ "use 'api_key' to set it.") end if driver.is_a?(Selenium::WebDriver::Driver) is_mobile_device = driver.capabilities['platformName'] ? true : false @driver = Applitools::Selenium::Driver.new(self, driver: driver, is_mobile_device: is_mobile_device) elsif defined?(Appium::Driver) && driver.is_a?(Appium::Driver) @driver = Applitools::Selenium::Driver.new(self, driver: driver.driver, is_mobile_device: true) elsif defined?(Watir::Browser) && driver.is_a?(Watir::Browser) is_mobile_device = driver.driver.capabilities['platformName'] ? true : false @driver = Applitools::Selenium::Driver.new(self, driver: driver.driver, is_mobile_device: is_mobile_device) else unless driver.is_a?(Applitools::Selenium::Driver) Applitools::EyesLogger.warn("Unrecognized driver type: (#{driver.class.name})!") is_mobile_device = driver.respond_to?(:capabilities) && driver.capabilities['platformName'] @driver = Applitools::Selenium::Driver.new(self, driver: driver, is_mobile_device: is_mobile_device) end end @driver.wait_before_screenshots = wait_before_screenshots if open? abort_if_not_closed msg = 'a test is already running' Applitools::EyesLogger.warn(msg) raise Applitools::EyesError.new(msg) end @user_inputs = [] @app_name = .fetch(:app_name) if @app_name.nil? || @app_name.empty? raise Applitools::EyesError.new('App name must be a non empty string.') end @test_name = .fetch(:test_name) if @test_name.nil? || @test_name.empty? raise Applitools::EyesError.new('Test name must be a non empty string.') end @viewport_size = .fetch(:viewport_size, nil) @is_open = true driver end |
#open? ⇒ Boolean
177 178 179 |
# File 'lib/applitools/eyes.rb', line 177 def open? is_open end |
#test(options = {}, &_block) ⇒ Object
Use this method to perform seamless testing with selenium through eyes driver. Using Selenium methods inside the ‘test’ block will send the messages to Selenium after creating the Eyes triggers for them.
Example:
eyes.test(app_name: 'my app1', test_name: 'my test') do |d|
get "http://www.google.com"
check_window("initial")
end
noinspection RubyUnusedLocalVariable
303 304 305 306 307 308 309 |
# File 'lib/applitools/eyes.rb', line 303 def test( = {}, &_block) open() yield(driver) close ensure abort_if_not_closed end |
#title ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/applitools/eyes.rb', line 92 def title unless @dont_get_title begin return driver.title rescue @dont_get_title = true end end '' end |