Created
May 28, 2019 20:21
-
-
Save elgatov/2d4acc4a9399d8e7fc194ab2ecd4bce8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool RetryingClick(this IWebElement element) | |
{ | |
bool clicked = false; | |
Stopwatch crono = Stopwatch.StartNew(); | |
while (crono.Elapsed < TimeSpan.FromSeconds(10) && !clicked ) | |
{ | |
try | |
{ | |
if (element != null && element.Displayed && element.Enabled) | |
{ | |
element.Click(); | |
clicked = true; | |
} | |
} | |
catch (WebDriverException) | |
{ } | |
Thread.Sleep(250); | |
} | |
if (clicked) | |
return true; | |
else | |
throw new WebDriverTimeoutException("El elemento no ha sido clicado en el tiempo límite. Finalizando ejecución"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment