Waiting for spinner to disappear does not work



  • I'm using the code below, waiting for "Loading" spinner to disappear. But I noticed that next test step does not wait until the spinner to disappear.

    Example:

    1. click on button_1 (after click, spinner is displayed)
    2. waiting until spinner to disappear
    3. click on button_2

    So, I noticed error because button_2 is unclickable until Loading spinner is displayed.

    How to deal with this situation, please?

    protected By LoadingSpinnerBy = By.XPath("//*[@id='loadingGrid']");
    
    /// <summary>
            /// Method to wait for page load to complete and loading spinner to be invisible
            /// </summary>
            public void WaitForLoadingSpinnerToGo()
            {
                if (_driver.FindElements(LoadingSpinnerBy).Count > 0)
                {
                    _wait.Until(ExpectedConditions.InvisibilityOfElementLocated(LoadingSpinnerBy));
                }
            }
    


  • Hi are you validating spinner to be visible first ?,

    _wait.Until(ExpectedConditions.visibilityOfElementLocated(LoadingSpinnerBy));
    

    sometimes spinner takes time to be displayed, and by that time your invisibility condition will be true. So you will have spinner being displayed in the next step

    The correct approach would be to:

    1. validate that spinner is displayed
    2. validate spinner gets disappeared
    3. validate button 2 is clickable


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2