title: Speeding up find_elements_by_css_selector in selenium
body: <p>With reference to this question <a href="https://sqa.stackexchange.com/questions/3481/quicker-way-to-assert-that-an-element-does-not-exist">https://sqa.stackexchange.com/questions/3481/quicker-way-to-assert-that-an-element-does-not-exist</a> I'm trying to write an <code>element_is_not_present</code> helper function:</p>
  
  <pre><code>def element_is_not_present(selector):
      self.d.implicitly_wait(0)
      number_present = len(self.d.find_elements_by_css_selector(selector))
      self.d.implicitly_wait(10)
  
      return number_present == 0
  </code></pre>
  
  <p><code>find_elements_by_css_selector</code> will wait for the implicit wait to timeout before returning so I have added mutators before and after the call to speed up the method. The issue comes in restoring the implicit wait, <a href="https://stackoverflow.com/questions/22871976/selenium-get-value-of-current-implicit-wait">apparently there is no getter for the implicit wait value</a>, so I must hard code the restore value causing issues when using a different base values.</p>
  
  <p>The question is, <strong>how can I speed up my method whilst negating this issue? Failing this, maybe there is another way of writing the helper method or dealing with the explicit wait?</strong></p>
  
  <hr>
  
  <p>My current solution is to use my own implicit wait default value global but this is far from ideal.</p>