I found that in C# whether the WebDriverWait class or the DefaultWait class , the IgnoreExceptionTypes method does not seem to work anyway.
those. in any case, when working with my page, a StaleElementReferenceException is StaleElementReferenceException , despite the fact that I instruct the code to ignore these exceptions.
WebDriverWait example:
public void WaitElementToBeClickable(IWebElement element) { var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(60)); wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException)); wait.Until(ExpectedConditions.ElementToBeClickable(element)); }
DefaultWait example:
public IWebElement SafeWaitForDisplayed(IWebElement webElement) { var w = new DefaultWait<IWebElement>(webElement); w.Timeout = TimeSpan.FromSeconds(30); w.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException)); return w.Until(ctx => { var elem = webElement; if (elem.Displayed) return elem; else return null; }); }
Any suggestions gratefully received. There seems to be very little on the Internet about using this particular method, while others believe that it also does not work without any workarounds.
source share