Reputation: 129
My test html:
<div id="mainBlock">
<div class="underBlock">
Hello!
</div>
</div>
i try to get content of div with class underBlock
like this:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless:false,
});
const page = await browser.newPage();
let response = await page.goto('http://localhost/TestPup/Index.html');
let block = await page.waitForXPath("//div[contains(@class,'underBlock')]")
let frame = await block.contentFrame()
console.log(frame.content())
await browser.close();
})();
but i got error:
TypeError: Cannot read property 'content' of null
Upvotes: 0
Views: 816
Reputation: 13772
As far as I understand, elementHandle.contentFrame()
only returns a frame for iframe
elements, and you have a regular div
that is contained in the main frame, that is, in the page
, and inside which there are no frames.
Upvotes: 1