testimio / root-cause

🔍 [DEPRECATED] Root Cause is a tool for troubleshooting Puppeteer and Playwright tests. 🔎
GNU Affero General Public License v3.0
266 stars 17 forks source link

Support page.mainFrame().evaluateHandle('document') #51

Open Bnaya opened 3 years ago

Bnaya commented 3 years ago

Calls to page.mainFrame() and Element handles acquired by frames, are not instrumented

As in use in: https://github.com/hoverinc/playwright-testing-library/blob/master/lib/index.ts#L147-L153

gioragutt commented 3 years ago

Copied for convenience.

export async function getDocument(_page?: Page): Promise<ElementHandle> {
  // @ts-ignore
  const page: Page = _page || this
  const documentHandle = await page.mainFrame().evaluateHandle('document')
  const document = documentHandle.asElement()
  if (!document) throw new Error('Could not find document')
  return document
}

@Bnaya How do you imagine this being instrumented? what would be the outcome?

Bnaya commented 3 years ago

I think that if we wrap mainFrame, frames and evaluateHandle can do we need to make sure puppeteer and playwright compat https://github.com/puppeteer/puppeteer/blob/3afe1935da5ee3b3a3ed8e910dd8dc280a0ae094/src/common/Page.ts The important outcome would be to have the operations on the element handles recored, the calls to mainFrame/frames are not very interesting i think

gioragutt commented 3 years ago

Doesn't it mean we just have to add the method names here?

Bnaya commented 3 years ago

Yes, kinda :)

gioragutt commented 3 years ago

Oh and also, since you're using Frame#evaluateHandle, you'd have to add either text mapping and/or selector mapping, depending on what input it can get...