chore(bidi): implement setInputFiles (#34757)

This commit is contained in:
Yury Semikhatsky 2025-02-12 12:49:05 -08:00 committed by GitHub
parent 0bd3a99f04
commit c2c336b97d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 2 deletions

View File

@ -530,11 +530,21 @@ export class BidiPage implements PageDelegate {
}
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
throw new Error('Method not implemented.');
throw new Error('Setting FilePayloads is not supported in Bidi.');
}
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, paths: string[]): Promise<void> {
throw new Error('Method not implemented.');
const fromContext = toBidiExecutionContext(handle._context);
const shared = await fromContext.rawCallFunction('x => x', { handle: handle._objectId });
// TODO: store sharedId in the handle.
if (!('sharedId' in shared))
throw new Error('Element is not a node');
const sharedId = shared.sharedId!;
await this._session.send('input.setFiles', {
context: this._session.sessionId,
element: { sharedId },
files: paths,
});
}
async adoptElementHandle<T extends Node>(handle: dom.ElementHandle<T>, to: dom.FrameExecutionContext): Promise<dom.ElementHandle<T>> {