input.fileDialogOpened eventThe 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.
The params field in the event notification is an object with the following fields:
contextA 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 OptionalAn 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.
multipleA 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 OptionalA string that contains the ID of the user context in which the file picker dialog was triggered.
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.
session.subscribe commandinput.setFiles commandinput.performActions commandinput.releaseActions command