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.

Event data

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

context

A string that contains the ID (UUID) of the context in which the file picker dialog was triggered. Context IDs are returned by commands such as browsingContext.getTree.

element Optional

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 Optional

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

Consider a scenario where a page has an <input type="file"> element that accepts a single file and your script calls click() on it. With a WebDriver BiDi connection and a subscription to input.fileDialogOpened active, the browser sends a notification when the file picker dialog opens:

json
{
  "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

Specification
WebDriver BiDi
# event-input-fileDialogOpened

Browser compatibility

See also