Stale element reference element is not attached to the page document. How to resolve?
Because your page is not fully loaded when Selenium searches for the element, the element in the DOM is not discovered. To fix this, add an explicit wait condition telling Selenium to wait until the element is ready to be clicked on.