MDN self-hosted library · e01.org

`input.fileDialogOpened` event

The input.fileDialogOpened event of the input module fires when a file picker dialog opens in a context, for example when click() or showPicker() is called on an <input type="file"> element.

no runnable cells webdriver-event upstream source

The input.fileDialogOpened event of the input module fires when a file picker dialog opens in a context, for example when click() or showPicker() is called on an <input type="file"> element.

Event data

The params field in the event notification is an object with the following fields:

  • context
  • : A string that contains the ID of the context in which the file picker dialog was triggered. Context IDs are returned by commands such as browsingContext.getTree.
  • element
  • : An object containing the ID that uniquely identifies the <input type="file"> DOM element that triggered the file picker dialog. This field is included when the file picker dialog is opened by a file <input> element.
  • multiple
  • : A boolean that indicates whether the file picker dialog allows multiple file paths.
    • true: The file picker dialog accepts multiple files (the associated <input> element has the multiple attribute).
    • false: The file picker dialog accepts only a single file path.
  • userContext
  • : A string that contains the ID of the user context in which the file picker dialog was triggered.

Examples

Receiving an event when a file picker dialog opens

Assume you have a WebDriver BiDi connection, an active session, and a subscription to input.fileDialogOpened active.

Suppose your page has an <input type="file"> element that accepts a single file and your script calls click() on the <input>. The browser sends the following notification when the file picker dialog opens:

{
  "type": "event",
  "method": "input.fileDialogOpened",
  "params": {
    "context": "5f07e3ca-ecac-465e-b9ef-49000c196ecf",
    "element": {
      "sharedId": "3be28343-afd3-4dea-a2b6-a863fbbb80e1"
    },
    "multiple": false
  }
}

You can then call input.setFiles with the element.sharedId from the notification to simulate file upload.

Specifications

Browser compatibility

See also