Get entire Playwright page in html and Text

Viewed 3695

I am using playwright in nodejs and I am having some problems when getting the page Text or Html. I just want to get the url as string like: <html><div class="123"><a>link</a>something</div><div>somethingelse</div></hmtl>

const browser = await playwright.chromium.launch({
    headless: true,
});

const page = await browser.newPage();
await page.goto(url);

I was trying to use const pageText = page.$('div').innerText; and also const pageText2 = await page.$$eval('div', el => el.innerText); But both do not work and just give me undefined.

1 Answers
Related