Question

How to getProperty in Playwright

I need to get a property from the element. How do I do that in playwright? I can do getAttribute but I don't see an option for getProperty?

 2  43  2
1 Jan 1970

Solution

 0

you can use the evaluate method to get a property from an element.

const propertyValue = await page.$eval(selector, (element, propertyName) => {
return (element as any)[propertyName];
}, 'propertyName');
2024-07-23
Avinash Chauhan