title: Selenium code for Instagram stuck loading images and stops working
body: <p>Instagram liking bot code works perfect until an image couldn't load on Instagram. Then it stops working, I need an <code>if</code> statement to handle a scenario like this.</p>
  
  <p>I don't know why but sometimes Instagram doesn't open images. It can be on the 4th one or the 50th one.</p>
  
  <p>I just need some code where:
  if Instagram couldn't find the like button, press next button. Here is what I have so far:</p>
  
  <pre><code>def likePhotos(self,amount):
      bot = self.bot
      bot.find_element_by_class_name('v1Nh3').click()
      i = 1
      while i &lt;= amount:
          time.sleep(2)
          bot.find_element_by_class_name('fr66n').click()
          time.sleep(1)
          bot.find_element_by_class_name('coreSpriteRightPaginationArrow').click()
          time.sleep(1)
      i += 1
  </code></pre>