Class: Playwright::FileChooser

Inherits:
PlaywrightApi show all
Defined in:
lib/playwright_api/file_chooser.rb,
sig/playwright.rbs

Overview

FileChooser objects are dispatched by the page in the [event: Page.fileChooser] event.

with page.expect_file_chooser() as fc_info:
    page.get_by_text("Upload file").click()
file_chooser = fc_info.value
file_chooser.set_files("myfile.pdf")

Instance Method Summary collapse

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

Constructor Details

This class inherits a constructor from Playwright::PlaywrightApi

Instance Method Details

#elementElementHandle

Returns input element associated with this file chooser.

Returns:



15
16
17
# File 'lib/playwright_api/file_chooser.rb', line 15

def element
  wrap_impl(@impl.element)
end

#multiple?Boolean

Returns whether this file chooser accepts multiple files.

Returns:

  • (Boolean)


21
22
23
# File 'lib/playwright_api/file_chooser.rb', line 21

def multiple?
  wrap_impl(@impl.multiple?)
end

#pagePage

Returns page this file chooser belongs to.

Returns:



27
28
29
# File 'lib/playwright_api/file_chooser.rb', line 27

def page
  wrap_impl(@impl.page)
end

#set_files(files, noWaitAfter: nil, timeout: nil) ⇒ void Also known as: files=

This method returns an undefined value.

Sets the value of the file input this chooser is associated with. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

Parameters:

  • files ((String | File), Array[untyped], Hash[untyped, untyped], Array[untyped])
  • noWaitAfter: (Boolean) (defaults to: nil)
  • timeout: (Float) (defaults to: nil)


34
35
36
# File 'lib/playwright_api/file_chooser.rb', line 34

def set_files(files, noWaitAfter: nil, timeout: nil)
  wrap_impl(@impl.set_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
end