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:
- click on button_1 (after click, spinner is displayed)
- waiting until spinner to disappear
- 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));
}
}