0

Now that ExpectedConditions is deprecated and I can't use ExpectedConditions.InvisibilityOfElementLocated to determine that a modal dialog has closed, is there a built-in easy way to determine that a modal dialog has closed using Selenium and C#?

public static void WaitForModalToClose(IWebDriver driver, int timeoutSec = 15)
{
    WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, timeoutSec));       
    wait.Until(ExpectedConditions.InvisibilityOfElementLocated(modal.getBy());
}

This gives me a deprecated warning.

Abdul Rauf
  • 5,798
  • 5
  • 50
  • 70
caris
  • 31
  • 1
  • 5

1 Answers1

2

Using nuget, search for DotNetSeleniumExtras.WaitHelpers, import that namespace into your class. Now you can do this:

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.InvisibilityOfElementLocated(modal.getBy()));

Find more details here: https://stackoverflow.com/a/49867605/7745522