diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index 54ef9b722a..510ae37107 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -900,6 +900,11 @@ export interface FrameBase { selector: string, options?: { visible?: boolean; hidden?: boolean; timeout?: number } ): Promise; + + waitForXPath( + xpath: string, + options?: { visible?: boolean; hidden?: boolean; timeout?: number } + ): Promise; } export interface Frame extends FrameBase { diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 043c2f5c78..05065e043a 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -117,9 +117,15 @@ puppeteer.launch().then(async browser => { await watchDog; let currentURL: string; + page .waitForSelector("img", { visible: true }) - .then(() => console.log("First URL with image: " + currentURL)); + .then(() => console.log("First URL with image by selector: " + currentURL)); + + page + .waitForXPath("//img", { visible: true }) + .then(() => console.log("First URL with image by xpath: " + currentURL)); + for (currentURL of [ "https://example.com", "https://google.com",