Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I've been working on a app in node.js using express.js and a number of other tools. I've been recently be trying to handle a common error that can result and while doing so I've been getting a specific error, that while in terminal, references a specific property I'm using (innerText) on a specific line (102).

(node:18517) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'innerText' of null
    at <anonymous>:1:102
    at ExecutionContext.evaluateHandle (/root/node_modules/puppeteer/lib/ExecutionContext.js:88:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)


Here is the original offending code, keep in mind the error above stays even when I delete it and re run the app.

const availability = await page.evaluate(() => {        const availabilityText = document.querySelector('.errorClass .errorClass')        return availabilityText ? availabilityText.innerText : "error";    });


What I have tried:

I've made drastic changes to the code. At temped to handle the error different ways. Added and deleted lines. Not used innerText anywhere near the line referenced. It still spits out the same error
Posted
Updated 11-Jul-18 11:18am
v3
Comments
Patrice T 11-Jul-18 16:21pm    
And you plan to show your code ?
DFNCTSC 11-Jul-18 17:04pm    
Much of it is proprietary. I will add some shortly when I can.

However, to your knowledge is there any reason for node to return the same error about the same property on the same line even when changes have been made. Including deleting the referenced lines, moving them around, etc.

edit:
const availability = await page.evaluate(() => {        const availabilityText = document.querySelector('.errorClass .errorClass')        return availabilityText ? availabilityText.innerText : "error";    });


Here is the code that should have been the original offending code.

This script uses puppeteer/headless chrome. I went to the page the app goes to, took a screenshot through the app and verified it was on the correct page, and tested the above function and confirmed the selector above exists and also existed in the screenshot taken by the app.

Keep in mind I can remove the above code and get the same error originally mentioned, exactly the same error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900