astral icon indicating copy to clipboard operation
astral copied to clipboard

add ElementHandle.parentElement

Open sigmaSd opened this issue 1 year ago • 3 comments

Is it expected to add such apis, I use them frequently like this ElementHandle.parentElement.children[1] for example

sigmaSd avatar Oct 29 '23 10:10 sigmaSd

puppetter also doesn't have this, seems the way to do this is with https://pptr.dev/api/puppeteer.page.evaluatehandle

sigmaSd avatar Oct 29 '23 10:10 sigmaSd

ElementHandle.parentElement.children[1]

The API as written is not technically feasible. At best (with the current API), it could be

await(await ElementHandle.parentElement()).children()[1]

we will be moving to locators soon, which solve this problem. With locators you could just do

Locator.parentElement.children[1]

and it could just work. TLDR; This is dependent on #2

lino-levan avatar Oct 30 '23 15:10 lino-levan

This trick works in puppeteer https://stackoverflow.com/a/66435477/6900891

sigmaSd avatar Aug 22 '24 22:08 sigmaSd