//public static IMyButton GetElement<T>(this ISearchContext element, By by) //{ // var test = element.GetElement<MyElement>(by, "test2"); // return test; //} public static T GetElement <T>(this ISearchContext searchContext, By by) where T : class { IWebDriver d = searchContext as IWebDriver; WebDriverWait waiter = new WebDriverWait(d, TimeSpan.FromSeconds(6)); waiter.Until(ExpectedConditions.ElementExists(by)); waiter.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by)); IWebElement webElemement = searchContext.FindElement(by); return(webElemement.As2 <T>(by, searchContext)); }