Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By waiting on a <code>bool</code> value instead of <code>IWebElement</code>, the .NET <code>WebDriverWait</code> class will wait until a value of <code>true</code> is returned. Given that, how about trying something like the following:</p> <pre><code>public static void WaitForElementToNotExist(string ID, IWebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until&lt;bool&gt;((d) =&gt; { try { // If the find succeeds, the element exists, and // we want the element to *not* exist, so we want // to return true when the find throws an exception. IWebElement element = d.FindElement(By.Id(ID)); return false; } catch (NoSuchElementException) { return true; } }); } </code></pre> <p>Note that this is the appropriate pattern if the element you're looking for is actually removed from the DOM. If, on the other hand, the "waiting" element is always present in the DOM, but just made visible/invisible as required by the JavaScript framework your app is using, then the code is a little simpler, and looks something like this:</p> <pre><code>public static void WaitForElementInvisible(string ID, IWebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until&lt;bool&gt;((d) =&gt; { try { IWebElement element = d.FindElement(By.Id(ID)); return !element.Displayed; } catch (NoSuchElementException) { // If the find fails, the element exists, and // by definition, cannot then be visible. return true; } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload