How to get text content on XPath expression
See original GitHub issueHi, I have like this.
var content = await page.$x("//span[@class='property-number']");
How to get text content inside that expression?
I already try with this, but not working.
var content = await page.evaluate(el => el.innerHTML, await page.$x("//span[@class='property-number']"));
Any help are appreciated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Get text content of an HTML element using XPath?
In the DOM Level 3 word you would select the p elements with e.g. //div[a[contains(., "Add to cart")]]/p and then access the textContent...
Read more >XPath in Selenium: How to Find & Write? (Text, Contains, ...
Contains () is a method used in XPath expression. It is used when the value of any attribute changes dynamically, for example, login...
Read more >How does XPath text work? | Examples
XPath text () function is a built-in function of the Selenium web driver that locates items based on their text. It aids in...
Read more >Introduction to using XPath in JavaScript - MDN Web Docs
This document describes the interface for using XPath in JavaScript internally, in extensions, and from websites. Mozilla implements a fair ...
Read more >Selecting content on a web page with XPath
XPath Expressions · XPath always assumes structured data. · Navigating through the HTML node tree using XPath · Navigating through a webpage with...
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
@sonyarianto the following should work:
This is the closest i have been able to get with my understanding `const browser = await puppeteer.launch();
const page = await browser.newPage(); await page.goto(‘https://example.com/’);
const title = await page.$x(“//h1”); let text = await title[0].getProperty(‘textContent’); console.log(text)
await browser.close();`