Update
The problem I am having is reproducible in Chrome without puppeteer. I can see the text in the browser but there is no way to access the data via the javascript console.
Original
facebook privacy settings page has options that are visible from the browser and I can inspect them. The problem is the values from document.querySelector are null.
Here's the url: https://www.facebook.com/settings
Here's the code
const el = await page.$x(
'/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[2]/div/ul/li[1]/div/div/ul/li[1]/a/span[3]/div/div[2]'
);
const v = await page.evaluate((div) => div.textContent, el[0]);
I've also tried by using JS Path
const v = await page.evaluate(
() =>
(<HTMLElement>(
document.querySelector(
'#u_fetchstream_2_4 > li:nth-child(1) > div > div > ul > li:nth-child(1) > a > span.fbSettingsListItemContent.fcg > div > div._nlm.fwb'
)
)).innerText
);
Always getting the following error:
Error: Evaluation failed: TypeError: Cannot read property 'innerText' of null
I've confirmed that the property is null UNTIL i right-click inspect any value on the page -- bot detection that still shows the page?!
Also tried using xpath in Chrome's console:
$x('//*[text()="Who can see your future posts?"]')
returns []
