title: Wait until loader disappears python selenium
body: <pre><code>&lt;div id="loader-mid" style="position: absolute; top: 118.5px; left: 554px; display: none;"&gt;
      &lt;div class="a"&gt;Loading&lt;/div&gt;
      &lt;div class="b"&gt;please wait...&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And want to wait until it disappears. I have following code but it wait sometimes too long and at some point of code it suddenly freeze all process and I don't know why.</p>
  
  <pre><code>from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.wait import WebDriverWait
  
  self.wait = WebDriverWait(driver, 10)
  
  self.wait.until(EC.invisibility_of_element_located((By.XPATH, "//*[@id='loader_mid'][contains(@style, 'display: block')]")))
  </code></pre>
  
  <p>and also I tried this one:</p>
  
  <pre><code>self.wait.until_not(EC.presence_of_element_located((By.XPATH, "//*[@id='loader_mid'][contains(@style, 'display: block')]")))
  </code></pre>
  
  <p>I don't know exactly how to check but maybe my element is always present on the page and selenium thought that it is there, the only thing that changes is parameter display changes from none to block. I think I can get attribute like string and check if there is word "block" but it is so wrong I thing... Help me please.</p>