Class: Playwright::Screencast
- Inherits:
-
Object
- Object
- Playwright::Screencast
- Defined in:
- lib/playwright/screencast.rb
Instance Method Summary collapse
- #hide_actions ⇒ Object
- #hide_overlays ⇒ Object
-
#initialize(page) ⇒ Screencast
constructor
A new instance of Screencast.
- #show_actions(duration: nil, fontSize: nil, position: nil) ⇒ Object
- #show_chapter(title, description: nil, duration: nil) ⇒ Object
- #show_overlay(html, duration: nil) ⇒ Object
- #show_overlays ⇒ Object
- #start(path: nil, size: nil, quality: nil, &on_frame) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(page) ⇒ Screencast
Returns a new instance of Screencast.
5 6 7 8 9 10 11 12 |
# File 'lib/playwright/screencast.rb', line 5 def initialize(page) @page = page @started = false @save_path = nil @artifact = nil @on_frame = nil @page.send(:channel).on('screencastFrame', method(:handle_screencast_frame)) end |
Instance Method Details
#hide_actions ⇒ Object
75 76 77 |
# File 'lib/playwright/screencast.rb', line 75 def hide_actions @page.send(:channel).('screencastHideActions') end |
#hide_overlays ⇒ Object
83 84 85 |
# File 'lib/playwright/screencast.rb', line 83 def @page.send(:channel).('screencastSetOverlayVisible', visible: false) end |
#show_actions(duration: nil, fontSize: nil, position: nil) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/playwright/screencast.rb', line 66 def show_actions(duration: nil, fontSize: nil, position: nil) params = {} params[:duration] = duration if duration params[:fontSize] = fontSize if fontSize params[:position] = position if position @page.send(:channel).('screencastShowActions', params) DisposableStub.new { hide_actions } end |
#show_chapter(title, description: nil, duration: nil) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/playwright/screencast.rb', line 59 def show_chapter(title, description: nil, duration: nil) params = { title: title } params[:description] = description if description params[:duration] = duration if duration @page.send(:channel).('screencastChapter', params) end |
#show_overlay(html, duration: nil) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/playwright/screencast.rb', line 49 def (html, duration: nil) params = { html: html } params[:duration] = duration if duration result = @page.send(:channel).('screencastShowOverlay', params) = result['id'] if result.is_a?(Hash) DisposableStub.new { @page.send(:channel).('screencastRemoveOverlay', id: ) if } end |
#show_overlays ⇒ Object
79 80 81 |
# File 'lib/playwright/screencast.rb', line 79 def @page.send(:channel).('screencastSetOverlayVisible', visible: true) end |
#start(path: nil, size: nil, quality: nil, &on_frame) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/playwright/screencast.rb', line 14 def start(path: nil, size: nil, quality: nil, &on_frame) raise 'Screencast is already started' if @started @started = true @on_frame = on_frame if on_frame params = {} params[:record] = true if path params[:size] = size if size params[:quality] = quality if quality params[:sendFrames] = true if on_frame result = @page.send(:channel).('screencastStart', params) if result.is_a?(Hash) && result['artifact'] @artifact = ChannelOwners::Artifact.from(result['artifact']) @save_path = path end DisposableStub.new { stop } end |
#stop ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/playwright/screencast.rb', line 35 def stop return unless @started @started = false @on_frame = nil @page.send(:channel).('screencastStop') if @save_path && @artifact @artifact.save_as(@save_path) end @artifact = nil @save_path = nil end |