I need to make this button clickable by completely removing the disabled="disabled" attribute from the element. Just changing the attribute value to something else doesn’t work for me.
Can someone show me how to completely delete this attribute from the DOM element? I would prefer to use page.$eval() method if possible. Thanks for any help!
You can delete the disabled attribute from your submit button using removeAttribute(). Here’s how with page.$eval():
await page.$eval('#send-form', element => {
element.removeAttribute('disabled');
});
This completely removes the attribute from the DOM so the button becomes clickable. Just make sure the page is fully loaded first to avoid null element errors. It works for any HTML attribute as well.
This works great with dynamic content where the element might not load right away. The null check stops errors if the selector finds nothing. Both methods do the same thing, but this one gives you better error handling for tricky scenarios.