diff options
Diffstat (limited to 'remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts')
-rw-r--r-- | remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts | 130 |
1 files changed, 1 insertions, 129 deletions
diff --git a/remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts b/remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts index 43fec58e37..9b1326f998 100644 --- a/remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts +++ b/remote/test/puppeteer/packages/puppeteer-core/src/api/ElementHandle.ts @@ -17,15 +17,10 @@ import type { NodeFor, } from '../common/types.js'; import type {KeyInput} from '../common/USKeyboardLayout.js'; -import { - debugError, - isString, - withSourcePuppeteerURLIfNone, -} from '../common/util.js'; +import {isString, withSourcePuppeteerURLIfNone} from '../common/util.js'; import {assert} from '../util/assert.js'; import {AsyncIterableUtil} from '../util/AsyncIterableUtil.js'; import {throwIfDisposed} from '../util/decorators.js'; -import {AsyncDisposableStack} from '../util/disposable.js'; import {_isElementHandle} from './ElementHandleSymbol.js'; import type { @@ -482,27 +477,6 @@ export abstract class ElementHandle< } /** - * @deprecated Use {@link ElementHandle.$$} with the `xpath` prefix. - * - * Example: `await elementHandle.$$('xpath/' + xpathExpression)` - * - * The method evaluates the XPath expression relative to the elementHandle. - * If `xpath` starts with `//` instead of `.//`, the dot will be appended - * automatically. - * - * If there are no such elements, the method will resolve to an empty array. - * @param expression - Expression to {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate | evaluate} - */ - @throwIfDisposed() - @ElementHandle.bindIsolatedHandle - async $x(expression: string): Promise<Array<ElementHandle<Node>>> { - if (expression.startsWith('//')) { - expression = `.${expression}`; - } - return await this.$$(`xpath/${expression}`); - } - - /** * Wait for an element matching the given selector to appear in the current * element. * @@ -587,84 +561,6 @@ export abstract class ElementHandle< } /** - * @deprecated Use {@link ElementHandle.waitForSelector} with the `xpath` - * prefix. - * - * Example: `await elementHandle.waitForSelector('xpath/' + xpathExpression)` - * - * The method evaluates the XPath expression relative to the elementHandle. - * - * Wait for the `xpath` within the element. If at the moment of calling the - * method the `xpath` already exists, the method will return immediately. If - * the `xpath` doesn't appear after the `timeout` milliseconds of waiting, the - * function will throw. - * - * If `xpath` starts with `//` instead of `.//`, the dot will be appended - * automatically. - * - * @example - * This method works across navigation. - * - * ```ts - * import puppeteer from 'puppeteer'; - * (async () => { - * const browser = await puppeteer.launch(); - * const page = await browser.newPage(); - * let currentURL; - * page - * .waitForXPath('//img') - * .then(() => console.log('First URL with image: ' + currentURL)); - * for (currentURL of [ - * 'https://example.com', - * 'https://google.com', - * 'https://bbc.com', - * ]) { - * await page.goto(currentURL); - * } - * await browser.close(); - * })(); - * ``` - * - * @param xpath - A - * {@link https://developer.mozilla.org/en-US/docs/Web/XPath | xpath} of an - * element to wait for - * @param options - Optional waiting parameters - * @returns Promise which resolves when element specified by xpath string is - * added to DOM. Resolves to `null` if waiting for `hidden: true` and xpath is - * not found in DOM, otherwise resolves to `ElementHandle`. - * @remarks - * The optional Argument `options` have properties: - * - * - `visible`: A boolean to wait for element to be present in DOM and to be - * visible, i.e. to not have `display: none` or `visibility: hidden` CSS - * properties. Defaults to `false`. - * - * - `hidden`: A boolean wait for element to not be found in the DOM or to be - * hidden, i.e. have `display: none` or `visibility: hidden` CSS properties. - * Defaults to `false`. - * - * - `timeout`: A number which is maximum time to wait for in milliseconds. - * Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The - * default value can be changed by using the {@link Page.setDefaultTimeout} - * method. - */ - @throwIfDisposed() - @ElementHandle.bindIsolatedHandle - async waitForXPath( - xpath: string, - options: { - visible?: boolean; - hidden?: boolean; - timeout?: number; - } = {} - ): Promise<ElementHandle<Node> | null> { - if (xpath.startsWith('//')) { - xpath = `.${xpath}`; - } - return await this.waitForSelector(`xpath/${xpath}`, options); - } - - /** * Converts the current handle to the given element type. * * @example @@ -1346,30 +1242,6 @@ export abstract class ElementHandle< const page = this.frame.page(); - // If the element is larger than the viewport, `captureBeyondViewport` will - // _not_ affect element rendering, so we need to adjust the viewport to - // properly render the element. - const viewport = page.viewport() ?? { - width: clip.width, - height: clip.height, - }; - await using stack = new AsyncDisposableStack(); - if (clip.width > viewport.width || clip.height > viewport.height) { - await this.frame.page().setViewport({ - ...viewport, - width: Math.max(viewport.width, Math.ceil(clip.width)), - height: Math.max(viewport.height, Math.ceil(clip.height)), - }); - - stack.defer(async () => { - try { - await this.frame.page().setViewport(viewport); - } catch (error) { - debugError(error); - } - }); - } - // Only scroll the element into view if the user wants it. if (scrollIntoView) { await this.scrollIntoViewIfNeeded(); |