Class: Puppeteer::Dialog
- Inherits:
-
Object
- Object
- Puppeteer::Dialog
- Defined in:
- lib/puppeteer/dialog.rb
Instance Attribute Summary collapse
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#accept(prompt_text = nil) ⇒ Object
prompt.
- #dismiss ⇒ Object
-
#initialize(client, type:, message:, default_value:) ⇒ Dialog
constructor
A new instance of Dialog.
Constructor Details
#initialize(client, type:, message:, default_value:) ⇒ Dialog
Returns a new instance of Dialog.
2 3 4 5 6 7 |
# File 'lib/puppeteer/dialog.rb', line 2 def initialize(client, type:, message:, default_value:) @client = client @type = type @message = @default_value = default_value || '' end |
Instance Attribute Details
#default_value ⇒ Object (readonly)
Returns the value of attribute default_value.
9 10 11 |
# File 'lib/puppeteer/dialog.rb', line 9 def default_value @default_value end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/puppeteer/dialog.rb', line 9 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/puppeteer/dialog.rb', line 9 def type @type end |
Instance Method Details
#accept(prompt_text = nil) ⇒ Object
prompt. Has no effect if the dialog’s type is not ‘prompt`.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppeteer/dialog.rb', line 15 def accept(prompt_text = nil) if @handled raise 'Cannot accept dialog which is already handled!' end @handled = true @client.('Page.handleJavaScriptDialog', { accept: true, promptText: prompt_text, }.compact) end |
#dismiss ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/puppeteer/dialog.rb', line 27 def dismiss if @handled raise 'Cannot accept dialog which is already handled!' end @handled = true @client.('Page.handleJavaScriptDialog', accept: false) end |