How can I get element attribute without evaluate function
See original GitHub issueHi puppeteer folks!
I am using evaluate
function for getting an attribute of web element.
Is there any way how to get attribute without evaluate
?
For example for these attributes:
countdown innerText
My code with evaluate function:
const xpath = ....
const await this.activePage.$x(xpath)
const attributeValue = await this.activePage.evaluate((obj, attr) => {
const single = obj[attr]
if (!single) return obj.getAttribute(attr)
return single
}, webElement, 'countdown')
I don`t want to use evaluate.
Thank you for any help!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Get the Value of HTML Attributes Using Puppeteer
You can get attribute value with evaluate method. await page.evaluate('document.querySelector("span.styleNumber").
Read more >Working with items and attributes - Amazon DynamoDB
A condition expression is a string containing attribute names, conditional operators, and built-in functions. The entire expression must evaluate to true.
Read more >Puppeteer - Getting Element Attribute - Tutorialspoint
We can get attribute values of an element using Puppeteer. The attributes are added within the HTML tag. They are used to describe...
Read more >XML - Robot Framework
Getting text or attributes of elements (e.g. Get Element Text and Get Element Attribute). Directly verifying text, attributes, or whole elements ...
Read more >XSL Transformations (XSLT) Version 3.0 - W3C
[ERR XTSE0010] It is a static error if an XSLT-defined element is used in a context where it is not permitted, if a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I missed out we can retrieve jsHandle for just an attribute via XPath. Try this:
If the attributes have property counterparts, you can use something like this: