diff --git a/src/common/Page.ts b/src/common/Page.ts index 7119ce6759f..4a2ecae2d63 100644 --- a/src/common/Page.ts +++ b/src/common/Page.ts @@ -694,14 +694,14 @@ export class Page extends EventEmitter { } /** - * @returns The browser this page belongs to. + * Get the browser the page belongs to. */ browser(): Browser { return this._target.browser(); } /** - * @returns The browser context that the page belongs to + * Get the browser context that the page belongs to. */ browserContext(): BrowserContext { return this._target.browserContext(); @@ -1085,12 +1085,27 @@ export class Page extends EventEmitter { return this.mainFrame().$$eval(selector, pageFunction, ...args); } + /** + * The method runs `document.querySelectorAll` within the page. If no elements + * match the selector, the return value resolves to `[]`. + * @remarks + * Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }. + * @param selector - A `selector` to query page for + */ async $$( selector: string ): Promise>> { return this.mainFrame().$$(selector); } + /** + * The method evaluates the XPath expression relative to the page document as + * its context node. If there are no such elements, the method resolves to an + * empty array. + * @remarks + * Shortcut for {@link Frame.$x | Page.mainFrame().$x(expression) }. + * @param expression - Expression to evaluate + */ async $x(expression: string): Promise { return this.mainFrame().$x(expression); } @@ -1148,6 +1163,13 @@ export class Page extends EventEmitter { await this._client.send('Network.setCookies', { cookies: items }); } + /** + * Adds a `