Module: Capybara::Playwright::DriverExtension
- Included in:
- Driver
- Defined in:
- lib/capybara/playwright/driver_extension.rb
Instance Method Summary collapse
-
#on_save_raw_screenshot_before_reset(&block) ⇒ Object
Register screenshot save process.
-
#on_save_screenrecord(&block) ⇒ Object
Register screenrecord save process.
-
#on_save_trace(&block) ⇒ Object
Register trace save process.
-
#start_tracing(name: nil, screenshots: false, snapshots: false, sources: false, title: nil) ⇒ Object
Start Playwright tracing (doc: playwright.dev/docs/api/class-tracing#tracing-start).
-
#stop_tracing(path: nil) ⇒ Object
Stop Playwright tracing (doc: playwright.dev/docs/api/class-tracing#tracing-stop).
-
#trace(name: nil, screenshots: false, snapshots: false, sources: false, title: nil, path: nil, &block) ⇒ Object
Trace execution of the given block.
- #with_playwright_page(&block) ⇒ Object
Instance Method Details
#on_save_raw_screenshot_before_reset(&block) ⇒ Object
Register screenshot save process. The callback is called just before page is closed. (just before #reset_session!)
The binary (String) of the page screenshot is called back into the given block
9 10 11 |
# File 'lib/capybara/playwright/driver_extension.rb', line 9 def on_save_raw_screenshot_before_reset(&block) @callback_on_save_screenshot = block end |
#on_save_screenrecord(&block) ⇒ Object
Register screenrecord save process. The callback is called just after page is closed. (just after #reset_session!)
The video path (String) is called back into the given block
26 27 28 |
# File 'lib/capybara/playwright/driver_extension.rb', line 26 def on_save_screenrecord(&block) @callback_on_save_screenrecord = block end |
#on_save_trace(&block) ⇒ Object
Register trace save process. The callback is called just after trace is saved.
The trace.zip path (String) is called back into the given block
42 43 44 |
# File 'lib/capybara/playwright/driver_extension.rb', line 42 def on_save_trace(&block) @callback_on_save_trace = block end |
#start_tracing(name: nil, screenshots: false, snapshots: false, sources: false, title: nil) ⇒ Object
Start Playwright tracing (doc: playwright.dev/docs/api/class-tracing#tracing-start)
53 54 55 56 57 58 59 60 |
# File 'lib/capybara/playwright/driver_extension.rb', line 53 def start_tracing(name: nil, screenshots: false, snapshots: false, sources: false, title: nil) # Ensure playwright page is initialized. browser with_playwright_page do |playwright_page| playwright_page.context.tracing.start(name: name, screenshots: screenshots, snapshots: snapshots, sources: sources, title: title) end end |
#stop_tracing(path: nil) ⇒ Object
Stop Playwright tracing (doc: playwright.dev/docs/api/class-tracing#tracing-stop)
63 64 65 66 67 |
# File 'lib/capybara/playwright/driver_extension.rb', line 63 def stop_tracing(path: nil) with_playwright_page do |playwright_page| playwright_page.context.tracing.stop(path: path) end end |
#trace(name: nil, screenshots: false, snapshots: false, sources: false, title: nil, path: nil, &block) ⇒ Object
Trace execution of the given block. The tracing is automatically stopped when the block is finished.
70 71 72 73 74 75 76 77 |
# File 'lib/capybara/playwright/driver_extension.rb', line 70 def trace(name: nil, screenshots: false, snapshots: false, sources: false, title: nil, path: nil, &block) raise ArgumentError.new('block must be given') unless block start_tracing(name: name, screenshots: screenshots, snapshots: snapshots, sources: sources, title: title) block.call ensure stop_tracing(path: path) end |
#with_playwright_page(&block) ⇒ Object
46 47 48 49 50 |
# File 'lib/capybara/playwright/driver_extension.rb', line 46 def with_playwright_page(&block) raise ArgumentError.new('block must be given') unless block @browser&.with_playwright_page(&block) end |