UIElement is no longer valid

This piece of information greatly helped me.
In my Robot, i click on print button and a new page opens up with the pdf save and print options. This is where I was having the element issues. I put the ctrl + F5 hotkey before doing anything on the website, and it fixed the issue for me. My program ran smoothly with not even a single instance of this issue after that. This solution is very specific to my case and I don’t know if it would help others.
Hope this is helpful. Cheers.