title: How to fix selenium calls to click on a button (in python)?
body: <p>I am trying to click on a WEB button in selenium, but this is more complicated than it sounds. Here is the python code I am using (inside a unit-test): </p>
  
  <pre><code>def search(self, key, value):
      """To return an element with the given key-value pair"""
      elements = self.driver.find_elements_by_xpath("//*[@%s]"%key)
      for element in elements:
          if element.get_attribute(key) == value:
              return element
      return None
  
  def test1(self):
      self.driver = webdriver.Firefox()
      self.driver.implicitly_wait(20)
      self.driver.get("https://www.swisscom.ch/de/privatkunden.html")
      button = self.search("data-tracking-title", "Mobile_Handys &amp; Tablets")
      element = self.driver.find_element_by_id("scs-pageheader-navigation-link-1")
      hover = ActionChains(self.driver).move_to_element(element)
      hover.perform()
      button.click()
  
      hrefs = self.driver.find_element_by_xpath("//div[@id='gridProduct10247118']")
  </code></pre>
  
  <p>with the error: </p>
  
  <pre><code>selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//div[@id='gridProduct10247118']"}
  </code></pre>
  
  <p>Well, the error makes sense, because selenium does not seem to have clicked on the <code>button</code>-element I searched for above. </p>
  
  <p>Why is selenium not performing the 'click' on that button? What do I miss here?</p>
  
  <p>P.S. Sometimes it does not work at all, the <code>button</code> is <code>None</code> in that case. One then needs to repeat the whole test UNCHANGED and maybe it will work then. How to fix that? I tried to increase the wait time, but it did not help either...</p>