Please share your experience on the timeouts implementation in case of Page Factory model.
In case of simple variable usage (var loginButton = driver.FindElement(By.Id("login")
), there are possibility to make extension like:
public static class WebDriverExtensions
{
public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
{
if (timeoutInSeconds > 0)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
return wait.Until(drv => drv.FindElement(by));
}
return driver.FindElement(by);
}
}
Code belongs to user Loudenvier
Reference to original discussion
But I can not add attributes to FindsByAttribute sealed class. At this moment my WebElements look like:
[FindsBy(How = How.Id, Using = "tbUsername")]
private IWebElement Username;