im having trouble getting the text that is listed in the element. I thought I did it right but i keep getting errors. This is the Element im trying to get. Any help would be great. Cant link the site because you have to login to get to this page.
<p><span class="query-player_current">1</span>
/
<span class="query-player_max">32</span></p>
(Trying to get the "1" and "32")^
and this is the code that i have.
const result = await page.evaluate (() => {
let playerCount = document.querySelector('query-player_current').innerText;
let playerCountMax = document.querySelector('query-player_max').innerText;
return {
playerCount,
playerCountMax
}
})
this is the errors im getting
Error: Evaluation failed: TypeError: Cannot read property 'innerText' of null
at __puppeteer_evaluation_script__:2:73
at ExecutionContext._evaluateInternal (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\ExecutionContext.js:122:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async ExecutionContext.evaluate (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\ExecutionContext.js:48:12)
at async downloadLog (C:\Users\logan\Desktop\GamerBot\commands\test2.js:56:20)
at async Object.module.exports.run (C:\Users\logan\Desktop\GamerBot\commands\test2.js:15:3)
-- ASYNC --
at ExecutionContext.<anonymous> (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\helper.js:111:15)
at DOMWorld.evaluate (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\DOMWorld.js:112:20)
-- ASYNC --
at Frame.<anonymous> (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\helper.js:111:15)
at Page.evaluate (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\Page.js:860:43)
at Page.<anonymous> (C:\Users\logan\Desktop\GamerBot\node_modules\puppeteer\lib\helper.js:112:23)
at downloadLog (C:\Users\logan\Desktop\GamerBot\commands\test2.js:56:31)
at async Object.module.exports.run (C:\Users\logan\Desktop\GamerBot\commands\test2.js:15:3)```
You have to use '.' as prefix, If you are using classnames in query. try
document.querySelector('.query-player_current')
document.querySelector('.query-player_max')