Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

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

Open
Bnaya opened this issue Oct 6, 2020 · 5 comments
Open

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

Bnaya opened this issue Oct 6, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@Bnaya
Copy link
Contributor

Bnaya commented Oct 6, 2020

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

@Bnaya Bnaya changed the title Wrap page.mainFrame().evaluateHandle('document') Support page.mainFrame().evaluateHandle('document') Oct 6, 2020
@Bnaya Bnaya added the enhancement New feature or request label Oct 6, 2020
@gioragutt
Copy link
Contributor

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
Copy link
Contributor Author

Bnaya commented Oct 13, 2020

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
Copy link
Contributor

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

@Bnaya
Copy link
Contributor Author

Bnaya commented Oct 13, 2020

Yes, kinda :)

@gioragutt
Copy link
Contributor

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...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants