title: Click button by find_element_by_class_name not working python selenium webdriver NOT working
body: <p>I'm trying to add contacts on LinkedIn using Python and Selenium. I'm attempting to do so by adding the contact suggestions made by LinkedIn in the "Network" tab (<a href="https://www.linkedin.com/mynetwork" rel="noreferrer">https://www.linkedin.com/mynetwork</a>), which has an infinite scroll feature.</p>
  
  <p>Basically I want the script to locate the button "Connect", which is next to each suggested profile, click the button, and then repeat until error whereby the script should scroll down to load more "Connect" buttons to reiterate.</p>
  
  <p>The best way I've found to locate the button element is by find_element_by_class_name() since all the connect buttons have the same class. I've also tried locating the elements using CSS and Xpath, without success.</p>
  
  <p>PROBLEM: The script is able to click the first Connect button, but none after that. I've tried many ideas for implementation (locating by Xpath, CSS, using a list of buttons to click), yet none seem to work. Below is the relevant part of the script.</p>
  
  <pre><code>while True:
      try:
          driver.find_element_by_class_name("mn-person-card__person-btn-ext.button-secondary-medium").click()
          time.sleep(1)
      except:
          pass
          print("trying to scroll")
          driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
          time.sleep(1) 
  </code></pre>
  
  <p>Any ideas? To me it seems as if the code should work, and as if there is something else which is preventing success. Maybe a bug or similar. Might mention that I'm rather new to all of this, and it's the first script I'm trying to make to manipulate a browser.</p>
  
  <p>I'm using Firefox driver. Full script can be found here: <a href="http://pastebin.com/qtdNsRtz" rel="noreferrer">http://pastebin.com/qtdNsRtz</a></p>
  
  <p>Thanks in advance!</p>