Написал вот такой метод Wait для ожидания елемента
public static bool Wait(this IWebDriver driver, By by, int timeout = 60)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));
wait.IgnoreExceptionTypes(typeof (NoSuchElementException));
return wait.Until(dr => dr.ElementIsPresent(by));
}
public static bool ElementIsPresent(this IWebDriver driver, By by)
{
try
{
return driver.FindElement(by).Displayed;
}
catch (NoSuchElementException)
{
return false;
}
}
вызываю его для несуществующего элемента на странице и почему-то сразу валюсь с ошибкой
_driver.Wait(By.Id(“some element”));
element: 'By.Id: some element' ---> OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"some element"}
В чем может быть проблема?