chore: add Page/Frame title method (#10260)

This commit is contained in:
Nikolay Vitkov 2023-05-30 10:36:22 +02:00 committed by GitHub
parent 73b72b31b2
commit a94dbceade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -270,6 +270,12 @@ export class BrowsingContext extends EventEmitter {
this.removeAllListeners(); this.removeAllListeners();
this.connection.unregisterBrowsingContexts(this.#id); this.connection.unregisterBrowsingContexts(this.#id);
} }
title(): Promise<string> {
return this.evaluate(() => {
return document.title;
});
}
} }
/** /**

View File

@ -111,6 +111,10 @@ export class Frame extends BaseFrame {
return this.#context.content(); return this.#context.content();
} }
override title(): Promise<string> {
return this.#context.title();
}
context(): BrowsingContext { context(): BrowsingContext {
return this.#context; return this.#context;
} }

View File

@ -496,6 +496,10 @@ export class Page extends PageBase {
this.#closedDeferred.valueOrThrow() this.#closedDeferred.valueOrThrow()
); );
} }
override title(): Promise<string> {
return this.mainFrame().title();
}
} }
function isConsoleLogEntry( function isConsoleLogEntry(