.NET Selenium NoSuchElementException; WebDriverWait.Until() doesn't work .NET Selenium NoSuchElementException; WebDriverWait.Until() doesn't work selenium selenium

.NET Selenium NoSuchElementException; WebDriverWait.Until() doesn't work


I decided to just not use WebDriverWait.Until(), and use implicit waits on the main driver instead:

driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

I give full credit to this answer on a different question for giving me the idea.


public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)        {            try            {                if (timeoutInSeconds > 0)                {                    var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));                    return wait.Until(drv => drv.FindElement(by));                }                return driver.FindElement(by);            }            catch            {                throw;            }        }

or if you are having

NoSuchElementException

try this code

 try        {            if (timeoutInSeconds > 0)            {                var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)).Until(ExpectedConditions.ElementIsVisible(by));            }            return driver.FindElement(by);        }        catch(Exception e)        {            throw;        }