GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Playwright for Python
  • Docs
  • API
  • Python
  • Node.js
  • Java
  • .NET
  • Community
  • Classes
  • APIRequestContext
  • APIResponse
  • Browser
  • BrowserContext
  • BrowserType

This view

  • Original page
  • New address

GeezerVison is showing playwright.dev — FileChooser | Playwright Python

This is unreleased documentation for Playwright Python Next version.
For up-to-date documentation, see the latest version (stable).
Version: Next

FileChooser objects are dispatched by the page in the page.on("filechooser") event.

  • Sync
  • Async
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")
async with page.expect_file_chooser() as fc_info:
await page.get_by_text("Upload file").click()
file_chooser = await fc_info.value
await file_chooser.set_files("myfile.pdf")

Methods​

set_files​

Added before v1.9 fileChooser.set_files

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.

Usage

file_chooser.set_files(files)
file_chooser.set_files(files, **kwargs)

Arguments

  • files Union[str, pathlib.Path] | List[Union[str, pathlib.Path]] | Dict | List[Dict]#

    • name str

      File name

    • mimeType str

      File type

    • buffer bytes

      File content

  • no_wait_after bool (optional)#

    Deprecated

    This option has no effect.

    This option has no effect.

  • timeout float (optional)#

    Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the browser_context.set_default_timeout() or page.set_default_timeout() methods.

Returns

  • NoneType#

Properties​

element​

Added before v1.9 fileChooser.element

Returns input element associated with this file chooser.

Usage

file_chooser.element

Returns

  • ElementHandle#

is_multiple​

Added before v1.9 fileChooser.is_multiple

Returns whether this file chooser accepts multiple files.

Usage

file_chooser.is_multiple()

Returns

  • bool#

page​

Added before v1.9 fileChooser.page

Returns page this file chooser belongs to.

Usage

file_chooser.page

Returns

  • Page#
  • Methods
    • set_files
  • Properties
    • element
    • is_multiple
    • page
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.