Class: Puppeteer::FileChooser

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/file_chooser.rb

Instance Method Summary collapse

Constructor Details

#initialize(element, event) ⇒ FileChooser

Returns a new instance of FileChooser.

Parameters:



4
5
6
7
8
# File 'lib/puppeteer/file_chooser.rb', line 4

def initialize(element, event)
  @element = element
  @multiple = event['mode'] != 'selectSingle'
  @handled = false
end

Instance Method Details

#accept(file_paths) ⇒ Object

Parameters:

  • file_paths (Array<String>)


15
16
17
18
19
20
21
# File 'lib/puppeteer/file_chooser.rb', line 15

def accept(file_paths)
  if @handled
    raise 'Cannot accept FileChooser which is already handled!'
  end
  @handled = true
  @element.upload_file(*file_paths)
end

#cancelObject



23
24
25
26
27
28
# File 'lib/puppeteer/file_chooser.rb', line 23

def cancel
  if @handled
    raise 'Cannot cancel FileChooser which is already handled!'
  end
  @handled = true
end

#multiple?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/puppeteer/file_chooser.rb', line 10

def multiple?
  @multiple
end