简体   繁体   中英

how to get the activeElement in puppeteer sharp

In order to find the activeElement in javascript puppeteer you use:

await page.evaluateHandle(() => document.activeElement);

But i cant find this in Puppeteer Sharp.

is there a way to do this?

I'm trying to find the activeElement, check if it has a certain innerText, and if so, click it.

You are after a handle, in this case an IElementHandle then you use EvaluateExpressionHandleAsync

var activeElement = await (IElementHandle)Page.EvaluateExpressionHandleAsync("document.activeElement");

There are more examples on GitHub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM