Using selenium for ui tests on our project. We are running the newest version 2.30.0. We use Firefox WebDriver and are running Firefox 19.0.
Generally said the ui te
public static IWebElement WaitForElementVisible(By selector, uint timeout = Config.DefaultTimeoutSec)
{
IWebDriver driver = Browser.Instance.Driver;
if (timeout > 0)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));
wait.Until(ExpectedConditions.ElementIsVisible(selector));
return driver.FindElement(selector);
}
else
{
// Search for element without timeout
return driver.FindElement(selector);
}
}
We use this to prevent such Element not found failures and it works like a charm.
There is also a different Version if the Element can be there, but doesn't have to be visible.
Just use ExpectedConditions.ElementExists(selector)
instead of ExpectedContitions.ElementIsVisible(selector)
edit: Browser.Instance.Driver is a class containing the instanced driver
Try this code:
DesiredCapabilities caps = DesiredCapabilities.Firefox();
//set the timeout to 120 seconds
IWebDriver driver = new RemoteWebDriver(new Uri("<app_url>"), caps, TimeSpan.FromSeconds(120));