🎥 Make videos programmatically with React
remove xpath functionality
Jonny Burger0a6bd0e8eb7f
diff --git a/packages/renderer/src/browser/DOMWorld.ts b/packages/renderer/src/browser/DOMWorld.tsindex 81612a7cfc..67f675f422 100644--- a/packages/renderer/src/browser/DOMWorld.ts+++ b/packages/renderer/src/browser/DOMWorld.ts@@ -392,54 +392,6 @@ export class DOMWorld {return elementHandle;}- async waitForXPath(- xpath: string,- options: WaitForSelectorOptions- ): Promise<ElementHandle | null> {- const {- visible: waitForVisible = false,- hidden: waitForHidden = false,- timeout = this.#timeoutSettings.timeout(),- } = options;- const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation';- const title = `XPath \`${xpath}\`${waitForHidden ? ' to be hidden' : ''}`;- function predicate(- root: Element | Document,- xpath: string,- waitForVisible: boolean,- waitForHidden: boolean- ): Node | null | boolean {- const node = document.evaluate(- xpath,- root,- null,- XPathResult.FIRST_ORDERED_NODE_TYPE,- null- ).singleNodeValue;- return checkWaitForOptions(node, waitForVisible, waitForHidden);- }-- const waitTaskOptions: WaitTaskOptions = {- domWorld: this,- predicateBody: makePredicateString(predicate),- predicateAcceptsContextElement: true,- title,- polling,- timeout,- args: [xpath, waitForVisible, waitForHidden],- root: options.root,- };- const waitTask = new WaitTask(waitTaskOptions);- const jsHandle = await waitTask.promise;- const elementHandle = jsHandle.asElement();- if (!elementHandle) {- await jsHandle.dispose();- return null;- }-- return elementHandle;- }-waitForFunction(pageFunction: Function | string,options: {polling?: string | number; timeout?: number} = {},diff --git a/packages/renderer/src/browser/JSHandle.ts b/packages/renderer/src/browser/JSHandle.tsindex 800e402a3e..aa070cf39b 100644--- a/packages/renderer/src/browser/JSHandle.ts+++ b/packages/renderer/src/browser/JSHandle.ts@@ -365,89 +365,6 @@ export class ElementHandle<this.#frameManager = frameManager;}- /**- * 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.- *- * This method works across navigation- * ```js- * const puppeteer = require('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.- * @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.- */- async waitForXPath(- xpath: string,- options: {- visible?: boolean;- hidden?: boolean;- timeout?: number;- } = {}- ): Promise<ElementHandle | null> {- const frame = this._context.frame();- assert(frame);- const secondaryContext = await frame._secondaryWorld.executionContext();- const adoptedRoot = await secondaryContext._adoptElementHandle(this);- xpath = xpath.startsWith('//') ? '.' + xpath : xpath;- if (!xpath.startsWith('.//')) {- await adoptedRoot.dispose();- throw new Error('Unsupported xpath expression: ' + xpath);- }-- const handle = await frame._secondaryWorld.waitForXPath(xpath, {- ...options,- root: adoptedRoot,- });- await adoptedRoot.dispose();- if (!handle) {- return null;- }-- const mainExecutionContext = await frame._mainWorld.executionContext();- const result = await mainExecutionContext._adoptElementHandle(handle);- await handle.dispose();- return result;- }-override asElement(): ElementHandle<ElementType> | null {return this;}