1

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;
Community
  • 1
  • 1
  • can you point to the place where you grabbed this code (like link to SO answer)? – drets Dec 22 '15 at 13:43
  • Sure, done. Original post updated. – Victor Kondin Dec 22 '15 at 15:07
  • Interesting question, +1, based on https://code.google.com/p/selenium/source/browse/dotnet/src/WebDriver.Support/PageObjects/ByFactory.cs?r=c7fce19f5446a5bd882f972ea574a8778449ef3a I think it's not possible to extend – drets Dec 22 '15 at 15:27

0 Answers0