lib/playwright_api/tracing.rb



module Playwright
  # API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
  # Playwright script runs.
  #
  # Start with specifying the folder traces will be stored in:
  #
  # ```python sync
  # browser = chromium.launch()
  # context = browser.new_context()
  # context.tracing.start(screenshots=True, snapshots=True)
  # page.goto("https://playwright.dev")
  # context.tracing.stop(path = "trace.zip")
  # ```
  class Tracing < PlaywrightApi

    # Start tracing.
    #
    # ```python sync
    # context.tracing.start(name="trace", screenshots=True, snapshots=True)
    # page.goto("https://playwright.dev")
    # context.tracing.stop()
    # context.tracing.stop(path = "trace.zip")
    # ```
    def start(name: nil, screenshots: nil, snapshots: nil)
      wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
    end

    # Stop tracing.
    def stop(path: nil)
      wrap_impl(@impl.stop(path: unwrap_impl(path)))
    end
  end
end