Class: Applitools::MatchWindowTask
- Inherits:
-
Object
- Object
- Applitools::MatchWindowTask
- Defined in:
- lib/eyes_selenium_ruby/eyes/match_window_task.rb
Defined Under Namespace
Classes: AppOutput
Constant Summary collapse
- MATCH_INTERVAL =
0.5
Instance Attribute Summary collapse
-
#agent_connector ⇒ Object
readonly
Returns the value of attribute agent_connector.
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#max_window_load_time ⇒ Object
readonly
Returns the value of attribute max_window_load_time.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#initialize(agent_connector, session, driver, max_window_load_time) ⇒ MatchWindowTask
constructor
A new instance of MatchWindowTask.
- #match_window(tag, run_once_after_wait = false) ⇒ Object
- #run(tag, wait_before_run = nil) ⇒ Object
- #run_with_intervals(tag, total_run_time) ⇒ Object
Constructor Details
#initialize(agent_connector, session, driver, max_window_load_time) ⇒ MatchWindowTask
Returns a new instance of MatchWindowTask.
11 12 13 14 15 16 17 18 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 11 def initialize(agent_connector, session, driver, max_window_load_time) @agent_connector = agent_connector @session = session @driver = driver @max_window_load_time = max_window_load_time @last_checked_window = nil # +ChunkyPNG::Canvas+ @current_screenshot = nil # +ChunkyPNG::Canvas+ end |
Instance Attribute Details
#agent_connector ⇒ Object (readonly)
Returns the value of attribute agent_connector.
9 10 11 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 9 def agent_connector @agent_connector end |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
9 10 11 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 9 def driver @driver end |
#max_window_load_time ⇒ Object (readonly)
Returns the value of attribute max_window_load_time.
9 10 11 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 9 def max_window_load_time @max_window_load_time end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
9 10 11 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 9 def session @session end |
Instance Method Details
#match_window(tag, run_once_after_wait = false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 20 def match_window(tag,run_once_after_wait=false) res = if max_window_load_time.zero? run(tag) elsif run_once_after_wait run(tag, max_window_load_time) else run_with_intervals(tag, max_window_load_time) end driver.clear_user_inputs and return res end |
#run(tag, wait_before_run = nil) ⇒ Object
32 33 34 35 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 32 def run(tag, wait_before_run=nil) sleep(wait_before_run) if wait_before_run match(tag) end |
#run_with_intervals(tag, total_run_time) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/eyes_selenium_ruby/eyes/match_window_task.rb', line 37 def run_with_intervals(tag, total_run_time) iterations = (total_run_time / MATCH_INTERVAL - 1).to_i iterations.times do sleep(MATCH_INTERVAL) return true if match(tag, true) end ## lets try one more time if we still don't have a match match(tag) end |