class Capybara::Cuprite::Browser::Page

def initialize(target_id, browser)

def initialize(target_id, browser)
  @wait = 0
  @target_id, @browser = target_id, browser
  @mutex, @resource = Mutex.new, ConditionVariable.new
  @network_traffic = []
  @frames = {}
  @waiting_frames ||= Set.new
  @frame_stack = []
  begin
    @session_id = @browser.command("Target.attachToTarget", targetId: @target_id)["sessionId"]
  rescue BrowserError => e
    if e.message == "No target with given id found"
      raise NoSuchWindowError
    else
      raise
    end
  end
  host = @browser.process.host
  port = @browser.process.port
  ws_url = "ws://#{host}:#{port}/devtools/page/#{@target_id}"
  @client = Client.new(browser, ws_url)
  subscribe_events
  prepare_page
end