1

I know about the three different types of waiting you can use in Selenium. I know why Thread.Sleep and ImplicitWait are never a good choice. So I'm always using ExplicitWaits, for instance to wait till a button is clickable. However, from time to time one or two tests in a collection of hundred tests fails because the Explictwait seems to fail.

I read the very interesting article: https://bocoup.com/weblog/a-day-at-the-races about the reason why tests can fail from time to time and Explicit wait as the solution for this intermittent failures. This made me even more convinced about using ExplictWaits.

So I wonder is there anybody who knows situations were an Explicitwait is not doing the right job.

This is my C# code for waiting till a Webelement is clickable:

    public static Boolean waitElementToBeClickable(IWebDriver driver, int seconds, IWebElement webelement)
    {
        Boolean clickable = true;
        try
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));
            wait.Until(ExpectedConditions.ElementToBeClickable(webelement));
        }
        catch
        {
            clickable = false;
        }
        return clickable;
    }
Frank
  • 831
  • 1
  • 11
  • 23
  • `Explicitwait` is doing right job while you might use it wrong. Show real example of issue, so we can help you to deal with it – Andersson Jan 17 '17 at 18:42
  • There was for example an issue with Bootstrap Modal Fade where my click on a button despite my ExplicitWait didn't reached the button but ended in the Bootstrap Dialog. I solved this issue with the help off: http://stackoverflow.com/questions/11546217/suggestions-for-getting-selenium-to-play-nice-with-bootstrap-modal-fade – Frank Jan 17 '17 at 19:00
  • Was it `chromedriver`? It seem to be `chromedriver` issue, but not `ExplicitWait`. You just need to use another condition for `ExplicitWait` – Andersson Jan 17 '17 at 19:03
  • This question is opinion based. You should read about `FluentWait`, and know that `ExplicitWait` is just a special case of fluent. – SiKing Jan 17 '17 at 19:15
  • It's chromedriver I use. What other condition do you suggest? – Frank Jan 17 '17 at 19:19
  • @Frank, Check this http://stackoverflow.com/questions/41632230/getting-element-is-not-clickable-exception-while-click-on-a-menu-link/41632565#41632565. It's `Java`, but the point is same for all programming languages. I hope I understood you correctly and this is exactly the same issue, you've faced – Andersson Jan 17 '17 at 19:27
  • 1
    @Andersson, Yes this is the same issue as I described in my comment. http://stackoverflow.com/questions/41632230/getting-element-is-not-clickable-exception-while-click-on-a-menu-link/41632565#41632565 is the same questions as http://stackoverflow.com/questions/11546217/suggestions-for-getting-selenium-to-play-nice-with-bootstrap-modal-fade I upvoted your answer in 41632230. When I will find another situation where ExplicitWait is not enough to finish a test succesful I come back with a new question. – Frank Jan 18 '17 at 07:08

0 Answers0