class Playwright::Video
Public Class Methods
new(page)
click to toggle source
# File lib/playwright/video.rb, line 3 def initialize(page) @page = page @artifact = Concurrent::Promises.resolvable_future if @page.closed? on_page_closed else page.once('close', -> { on_page_closed }) end end
Public Instance Methods
delete()
click to toggle source
# File lib/playwright/video.rb, line 36 def delete wait_for_artifact_and do |artifact| artifact.delete end end
path()
click to toggle source
# File lib/playwright/video.rb, line 24 def path wait_for_artifact_and do |artifact| artifact.absolute_path end end
save_as(path)
click to toggle source
# File lib/playwright/video.rb, line 30 def save_as(path) wait_for_artifact_and do |artifact| artifact.save_as(path) end end
Private Instance Methods
on_page_closed()
click to toggle source
# File lib/playwright/video.rb, line 13 def on_page_closed unless @artifact.resolved? @artifact.reject('Page closed') end end
set_artifact(artifact)
click to toggle source
called only from Page#on_video via send(:set_artifact, artifact)
# File lib/playwright/video.rb, line 20 def set_artifact(artifact) @artifact.fulfill(artifact) end
wait_for_artifact_and(&block)
click to toggle source
# File lib/playwright/video.rb, line 42 def wait_for_artifact_and(&block) artifact = @artifact.value! unless artifact raise 'Page did not produce any video frames' end block.call(artifact) end