Reputation: 67
I'm using the following in puppeteer to try return the number in the inner text of the below element. I've tried many different ways but keep getting an empty object returned, what am I doing wrong?!
if (await page.$('.s-pagination-item.s-pagination-next.s-pagination-button.s-pagination-separator') !== null) {
var lastPageNumber = await page.evaluate(() => document.querySelector('s-pagination-item.s-pagination-disabled'), a => a.innerText);
} else {
var lastPageNumber = 1;
}
Upvotes: 1
Views: 79
Reputation: 16838
To get the innerText
value of a given object you would need to do it like this:
var lastPageNumber = await page.evaluate(
() => document.querySelector('s-pagination-item.s-pagination-disabled').innerText
);
Upvotes: 1