Skip to content

Commit

Permalink
chore: add documentation to xpath prefix and deprecated page.waitForT…
Browse files Browse the repository at this point in the history
…imeout (#9014)
  • Loading branch information
pecampelo authored and jrandolf committed Oct 4, 2022
1 parent 5dbd69e commit b7b07e3
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 9 deletions.
6 changes: 5 additions & 1 deletion docs/api/puppeteer.elementhandle._x.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ sidebar_label: ElementHandle.$x
>
> Use [ElementHandle.$$()](./puppeteer.elementhandle.__.md) with the `xpath` prefix.
>
> The method evaluates the XPath expression relative to the elementHandle. If there are no such elements, the method will resolve to an empty array.
> 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.
**Signature:**

Expand Down
6 changes: 5 additions & 1 deletion docs/api/puppeteer.elementhandle.waitforxpath.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ sidebar_label: ElementHandle.waitForXPath
>
> Use [ElementHandle.waitForSelector()](./puppeteer.elementhandle.waitforselector.md) 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.
>
> This method works across navigation
> This method works across navigation.
>
> ```ts
> const puppeteer = require('puppeteer');
Expand Down
4 changes: 3 additions & 1 deletion docs/api/puppeteer.frame._x.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ sidebar_label: Frame.$x
>
> Use [Frame.$$()](./puppeteer.frame.__.md) with the `xpath` prefix.
>
> This method evaluates the given XPath expression and returns the results.
> Example: `await frame.$$('xpath/' + xpathExpression)`
>
> This method evaluates the given XPath expression and returns the results. If `xpath` starts with `//` instead of `.//`, the dot will be appended automatically.
**Signature:**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/puppeteer.frame.waitfortimeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Frame.waitForTimeout

> Warning: This API is now obsolete.
>
> Use `new Promise(r => setTimeout(r, milliseconds));`.
> Replace with `new Promise(r => setTimeout(r, milliseconds));`.
>
> Causes your script to wait for the given number of milliseconds.
Expand Down
4 changes: 4 additions & 0 deletions docs/api/puppeteer.frame.waitforxpath.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ sidebar_label: Frame.waitForXPath
>
> Use [Frame.waitForSelector()](./puppeteer.frame.waitforselector.md) with the `xpath` prefix.
>
> Example: `await frame.waitForSelector('xpath/' + xpathExpression)`
>
> The method evaluates the XPath expression relative to the Frame. If `xpath` starts with `//` instead of `.//`, the dot will be appended automatically.
>
> Wait for the `xpath` to appear in page. 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.
>
> For a code example, see the example for [Frame.waitForSelector()](./puppeteer.frame.waitforselector.md). That function behaves identically other than taking a CSS selector rather than an XPath.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/puppeteer.page.waitfortimeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Page.waitForTimeout

> Warning: This API is now obsolete.
>
> Use `new Promise(r => setTimeout(r, milliseconds));`.
> Replace with `new Promise(r => setTimeout(r, milliseconds));`.
>
> Causes your script to wait for the given number of milliseconds.
Expand Down
2 changes: 1 addition & 1 deletion src/api/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2334,7 +2334,7 @@ export class Page extends EventEmitter {
}

/**
* @deprecated Use `new Promise(r => setTimeout(r, milliseconds));`.
* @deprecated Replace with `new Promise(r => setTimeout(r, milliseconds));`.
*
* Causes your script to wait for the given number of milliseconds.
*
Expand Down
11 changes: 10 additions & 1 deletion src/common/ElementHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ export 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}
*/
Expand Down Expand Up @@ -336,6 +341,10 @@ export 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
Expand All @@ -344,7 +353,7 @@ export class ElementHandle<
* If `xpath` starts with `//` instead of `.//`, the dot will be appended
* automatically.
*
* This method works across navigation
* This method works across navigation.
*
* ```ts
* const puppeteer = require('puppeteer');
Expand Down
12 changes: 11 additions & 1 deletion src/common/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,11 @@ export class Frame {
/**
* @deprecated Use {@link Frame.$$} with the `xpath` prefix.
*
* Example: `await frame.$$('xpath/' + xpathExpression)`
*
* This method evaluates the given XPath expression and returns the results.
* If `xpath` starts with `//` instead of `.//`, the dot will be appended
* automatically.
* @param expression - the XPath expression to evaluate.
*/
async $x(expression: string): Promise<Array<ElementHandle<Node>>> {
Expand Down Expand Up @@ -610,6 +614,12 @@ export class Frame {
/**
* @deprecated Use {@link Frame.waitForSelector} with the `xpath` prefix.
*
* Example: `await frame.waitForSelector('xpath/' + xpathExpression)`
*
* The method evaluates the XPath expression relative to the Frame.
* If `xpath` starts with `//` instead of `.//`, the dot will be appended
* automatically.
*
* Wait for the `xpath` to appear in page. 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
Expand Down Expand Up @@ -1020,7 +1030,7 @@ export class Frame {
}

/**
* @deprecated Use `new Promise(r => setTimeout(r, milliseconds));`.
* @deprecated Replace with `new Promise(r => setTimeout(r, milliseconds));`.
*
* Causes your script to wait for the given number of milliseconds.
*
Expand Down
2 changes: 1 addition & 1 deletion src/common/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@ export class CDPPage extends Page {
}

/**
* @deprecated Use `new Promise(r => setTimeout(r, milliseconds));`.
* @deprecated Replace with `new Promise(r => setTimeout(r, milliseconds));`.
*
* Causes your script to wait for the given number of milliseconds.
*
Expand Down

0 comments on commit b7b07e3

Please sign in to comment.