Sha256: dbb7da3c83c11803054e5dacbc3bb10f01ee41dfb0565cfdbe94bc0025aaa075

Contents?: true

Size: 997 Bytes

Versions: 61

Compression:

Stored size: 997 Bytes

Contents

class Puppeteer::Dialog
  def initialize(client, type:, message:, default_value:)
    @client = client
    @type = type
    @message = message
    @default_value = default_value || ''
  end

  attr_reader :type, :message, :default_value

  # @param prompt_text - optional text that will be entered in the dialog
  # prompt. Has no effect if the dialog's type is not `prompt`.
  #
  # @returns A promise that resolves when the dialog has been accepted.
  def accept(prompt_text = nil)
    if @handled
      raise 'Cannot accept dialog which is already handled!'
    end
    @handled = true
    @client.send_message('Page.handleJavaScriptDialog', {
      accept: true,
      promptText: prompt_text,
    }.compact)
  end

  # @returns A promise which will resolve once the dialog has been dismissed
  def dismiss
    if @handled
      raise 'Cannot accept dialog which is already handled!'
    end
    @handled = true
    @client.send_message('Page.handleJavaScriptDialog', accept: false)
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
puppeteer-ruby-0.40.4 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.3 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.39.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.38.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.37.4 lib/puppeteer/dialog.rb
puppeteer-ruby-0.37.3 lib/puppeteer/dialog.rb
puppeteer-ruby-0.37.2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.37.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.37.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.36.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.35.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.35.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.34.3 lib/puppeteer/dialog.rb
puppeteer-ruby-0.34.2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.34.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.34.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.33.0 lib/puppeteer/dialog.rb