Got it figured out I was calling the evaluate on the button it needs to be called on Page object with the reference passed of button element
try{
await popupPage.evaluate(button => button.click(), connectButton);
console.log('Connect button clicked.');
await delay(5000);
}
catch(error){
console.log('Error clicking connect button:', error);
}