Skip to content

Instantly share code, notes, and snippets.

@safestudent
Created September 19, 2018 16:46
Show Gist options
  • Save safestudent/dd5de704eb6f54893edc554b6652205b to your computer and use it in GitHub Desktop.
Save safestudent/dd5de704eb6f54893edc554b6652205b to your computer and use it in GitHub Desktop.
Wait for Element
public static IWebElement WaitForElement(By locator)
{
// Here we set the timeout as 5 second, 0 minutes and 0 hours
WebDriverWait wait = new WebDriverWait(Browser, new TimeSpan(0, 0, 5));
// Here we set the `Until` condition as until the browser finds the element. If it find the element in 5 seconds, it will return it.
return wait.Until(Browser => Browser.FindElement(locator));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment