Class: Applitools::Selenium::RunningTest
- Inherits:
-
Object
- Object
- Applitools::Selenium::RunningTest
- Extended by:
- Forwardable
- Defined in:
- lib/applitools/selenium/visual_grid/running_test.rb
Instance Attribute Summary collapse
-
#browser_info ⇒ Object
Returns the value of attribute browser_info.
-
#close_queue ⇒ Object
Returns the value of attribute close_queue.
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#eyes ⇒ Object
Returns the value of attribute eyes.
-
#on_results ⇒ Object
Returns the value of attribute on_results.
-
#open_queue ⇒ Object
Returns the value of attribute open_queue.
-
#pending_exceptions ⇒ Object
Returns the value of attribute pending_exceptions.
-
#render_queue ⇒ Object
Returns the value of attribute render_queue.
-
#task_lock ⇒ Object
Returns the value of attribute task_lock.
-
#task_queue ⇒ Object
Returns the value of attribute task_queue.
-
#test_result ⇒ Object
Returns the value of attribute test_result.
-
#test_uuid ⇒ Object
Returns the value of attribute test_uuid.
-
#watch_close ⇒ Object
Returns the value of attribute watch_close.
-
#watch_open ⇒ Object
Returns the value of attribute watch_open.
-
#watch_render ⇒ Object
Returns the value of attribute watch_render.
-
#watch_task ⇒ Object
Returns the value of attribute watch_task.
Instance Method Summary collapse
- #abort ⇒ Object
- #all_tasks_completed?(watch) ⇒ Boolean
- #check(tag, target, render_task, title) ⇒ Object
- #init ⇒ Object
-
#initialize(eyes, browser_info, driver) ⇒ RunningTest
constructor
A new instance of RunningTest.
- #on_results_received(&block) ⇒ Object
Constructor Details
#initialize(eyes, browser_info, driver) ⇒ RunningTest
Returns a new instance of RunningTest.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 138 def initialize(eyes, browser_info, driver) Applitools::ArgumentGuard.is_a? eyes, 'eyes', Applitools::Selenium::EyesConnector self.eyes = eyes self.browser_info = browser_info self.driver = driver self.open_queue = [] self.task_queue = [] self.render_queue = [] self.close_queue = [] self.watch_open = {} self.watch_task = {} self.watch_render = {} self.watch_close = {} self.task_lock = nil self.pending_exceptions = [] super() init end |
Instance Attribute Details
#browser_info ⇒ Object
Returns the value of attribute browser_info.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def browser_info @browser_info end |
#close_queue ⇒ Object
Returns the value of attribute close_queue.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def close_queue @close_queue end |
#driver ⇒ Object
Returns the value of attribute driver.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def driver @driver end |
#eyes ⇒ Object
Returns the value of attribute eyes.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def eyes @eyes end |
#on_results ⇒ Object
Returns the value of attribute on_results.
12 13 14 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 12 def on_results @on_results end |
#open_queue ⇒ Object
Returns the value of attribute open_queue.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def open_queue @open_queue end |
#pending_exceptions ⇒ Object
Returns the value of attribute pending_exceptions.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def pending_exceptions @pending_exceptions end |
#render_queue ⇒ Object
Returns the value of attribute render_queue.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def render_queue @render_queue end |
#task_lock ⇒ Object
Returns the value of attribute task_lock.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def task_lock @task_lock end |
#task_queue ⇒ Object
Returns the value of attribute task_queue.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def task_queue @task_queue end |
#test_result ⇒ Object
Returns the value of attribute test_result.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def test_result @test_result end |
#test_uuid ⇒ Object
Returns the value of attribute test_uuid.
136 137 138 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 136 def test_uuid @test_uuid end |
#watch_close ⇒ Object
Returns the value of attribute watch_close.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def watch_close @watch_close end |
#watch_open ⇒ Object
Returns the value of attribute watch_open.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def watch_open @watch_open end |
#watch_render ⇒ Object
Returns the value of attribute watch_render.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def watch_render @watch_render end |
#watch_task ⇒ Object
Returns the value of attribute watch_task.
133 134 135 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 133 def watch_task @watch_task end |
Instance Method Details
#abort ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 166 def abort return unless close_queue.empty? self.test_result = nil close_task = Applitools::Selenium::VGTask.new("abort #{browser_info}") do eyes.abort end close_task.on_task_error do |e| pending_exceptions << e end close_task.on_task_completed do watch_close[close_task] = true becomes_completed if all_tasks_completed?(watch_close) end close_queue << close_task watch_close[close_task] = false end |
#all_tasks_completed?(watch) ⇒ Boolean
263 264 265 266 267 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 263 def all_tasks_completed?(watch) return true if state_name == :completed uniq_values = watch.values.uniq uniq_values.count == 1 && uniq_values.first == true end |
#check(tag, target, render_task, title) ⇒ Object
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 226 227 228 229 230 231 232 233 234 235 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 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 200 def check(tag, target, render_task, title) eyes.title = title result_index = render_task.add_running_test(self) check_task = VGTask.new("perform check #{tag} #{target}") do eyes.check(tag, target, render_task.uuid) end check_task.on_task_completed do watch_task[check_task] = true self.task_lock = nil if task_lock.uuid == check_task.uuid becomes_tested if all_tasks_completed?(watch_task) end task_queue.insert(0, check_task) watch_task[check_task] = false render_task.on_task_succeeded do |r| if r[result_index] && r[result_index]['status'] == 'rendered' eyes.render_status_for_task(render_task.uuid, r[result_index]) watch_render[render_task] = true becomes_rendered if all_tasks_completed?(watch_render) elsif r[result_index] && r[result_index]['status'] == 'error' watch_render[render_task] = true task_queue.clear watch_task.clear close_queue.clear watch_close.clear check_task = VGTask.new("perform check #{tag} #{target}") do logger.error('Running empty test due to render error...') eyes.ensure_running_session end check_task.on_task_completed do watch_task[check_task] = true self.task_lock = nil if task_lock.uuid == check_task.uuid becomes_tested if all_tasks_completed?(watch_task) end eyes.render_status_for_task( render_task.uuid, r[result_index].merge('deviceSize' => browser_info.) ) eyes.current_uuid = render_task.uuid task_queue.insert(0, check_task) watch_task[check_task] = false abort becomes_rendered if all_tasks_completed?(watch_render) else logger.error "Wrong render status! Render returned status #{r[result_index]['status']}" becomes_completed end end render_task.on_task_error do becomes_completed end watch_render[render_task] = false end |
#init ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 183 def init open_task = Applitools::Selenium::VGTask.new("open #{browser_info}") { eyes.open(driver, browser_info) } open_task.on_task_succeeded do watch_open[open_task] = true becomes_opened if all_tasks_completed?(watch_open) end open_task.on_task_error do |e| pending_exceptions << e becomes_completed end open_queue << open_task watch_open[open_task] = false end |
#on_results_received(&block) ⇒ Object
162 163 164 |
# File 'lib/applitools/selenium/visual_grid/running_test.rb', line 162 def on_results_received(&block) self.on_results = block if block_given? end |