feat(driver): add reuse and navigate commands (#16420)
This commit is contained in:
parent
16d9f66ff9
commit
c84fbc2e4e
|
|
@ -92,6 +92,19 @@ class ProtocolHandler {
|
||||||
this._playwright = playwright;
|
this._playwright = playwright;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetForReuse() {
|
||||||
|
const contexts = new Set<BrowserContext>();
|
||||||
|
for (const page of this._playwright.allPages())
|
||||||
|
contexts.add(page.context());
|
||||||
|
for (const context of contexts)
|
||||||
|
await context.resetForReuse(internalMetadata, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
async navigate(params: { url: string }) {
|
||||||
|
for (const p of this._playwright.allPages())
|
||||||
|
await p.mainFrame().goto(internalMetadata, params.url);
|
||||||
|
}
|
||||||
|
|
||||||
async setMode(params: { mode: Mode, language?: string, file?: string }) {
|
async setMode(params: { mode: Mode, language?: string, file?: string }) {
|
||||||
await gc(this._playwright);
|
await gc(this._playwright);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,12 +157,14 @@ export abstract class BrowserContext extends SdkObject {
|
||||||
return JSON.stringify(paramsCopy);
|
return JSON.stringify(paramsCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetForReuse(metadata: CallMetadata, params: channels.BrowserNewContextForReuseParams) {
|
async resetForReuse(metadata: CallMetadata, params: channels.BrowserNewContextForReuseParams | null) {
|
||||||
this.setDefaultNavigationTimeout(undefined);
|
this.setDefaultNavigationTimeout(undefined);
|
||||||
this.setDefaultTimeout(undefined);
|
this.setDefaultTimeout(undefined);
|
||||||
|
|
||||||
for (const key of paramsThatAllowContextReuse)
|
if (params) {
|
||||||
(this._options as any)[key] = params[key];
|
for (const key of paramsThatAllowContextReuse)
|
||||||
|
(this._options as any)[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
await this._cancelAllRoutesInFlight();
|
await this._cancelAllRoutesInFlight();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue