chore(bidi): implement setInputFiles (#34757)
This commit is contained in:
parent
0bd3a99f04
commit
c2c336b97d
|
|
@ -530,11 +530,21 @@ export class BidiPage implements PageDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
|
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> {
|
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>> {
|
async adoptElementHandle<T extends Node>(handle: dom.ElementHandle<T>, to: dom.FrameExecutionContext): Promise<dom.ElementHandle<T>> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue