title: selenium with python - automated clicking on elements with skipping specific html class
body: <p>It's just a simple crawler that clicks on elements. It works just fine but I need a last feature - skipping specific html class.</p>
  
  <p>Script gets element then likes it and then go to the next one.
  Here is the code:</p>
  
  <pre><code>for i in range(len(driver.find_elements_by_class_name("upvote"))):
      driver.find_elements_by_class_name("upvote")[i].click()
      print("Liked media.")
      time.sleep(8)
  </code></pre>
  
  <p>This for loop finds my desired class "upvote" and then clicks on it. It's correct, but when I already liked some elements, my script likes it again and it's == dislike.
  Already liked media has class of "upvote active".</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver import ChromeOptions
  from selenium.webdriver.common.keys import Keys
  import time
  
  options = webdriver.ChromeOptions()
  options.add_argument("--headless")
  driver = webdriver.Chrome()
  
  accountActive = "xxxxxx"
  
  driver.get('https://www.example.com/User/Login?ReturnUrl=%2FProfile')
  time.sleep(3)
  print("Trying to login as " + accountActive)
  
  account = driver.find_element_by_id("Email")
  account.clear() #clear input
  account.send_keys("xxxx")
  #elem.send_keys(Keys.RETURN)
  
  
  passwd = driver.find_element_by_id("Password")
  passwd.clear() #clear input
  passwd.send_keys("xxxx")
  passwd.send_keys(Keys.RETURN)
  print("Login successfull.")
  time.sleep(3)
  
  
  print("Getting xxxx.")
  driver.get("https://www.exaple.com/Codes/")
  time.sleep(3)
  
  
  print("xxxx.")
  driver.get("https://example.com/Codes?ordering=MostRecent&amp;language=")
  time.sleep(3)
  
  
  j=0
  while j&lt;5:
      for i in range(len(driver.find_elements_by_class_name("upvote"))):
          driver.find_elements_by_class_name("upvote")[i].click()
          print("Liked media.")
          time.sleep(8)
  
      driver.find_elements_by_tag_name("a")[93].click()
      time.sleep(10)
      j+=1
  </code></pre>