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.45.6 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.5 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.4 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.3 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.2.alpha2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.2.alpha1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.45.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.44.3 lib/puppeteer/dialog.rb
puppeteer-ruby-0.44.2 lib/puppeteer/dialog.rb
puppeteer-ruby-0.44.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.44.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.43.1 lib/puppeteer/dialog.rb
puppeteer-ruby-0.43.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.42.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.41.0 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.7 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.6 lib/puppeteer/dialog.rb
puppeteer-ruby-0.40.5 lib/puppeteer/dialog.rb