I'm new to using Selenium and ChromeDriver in C#. I'm trying to click a button element that disappears after clicking it, so I'm getting a StaleElementReferenceException.
IWebElement LoadMoreButton = Driver.FindElementsByTagName("button");
LoadMoreButton.Click();
I'm trying to catch this exception. I can't however, since it's thrown by chromedriver.exe itself and not by my program!! So doing a try-catch won't do anything.
Any ideas? On the other hand, what would be the best approach for clicking a button that will be gone from the DOM?