title: Selenium Instagram Bot Follower
body: <p>I want to open an Instagram account, tap on their follower and follow all their followers. So I've written a selenium program. This code opens profile, then login with my username and password then tap on the followers, But after that, it doesn't follow all the followers. Please help.</p>
  <pre><code>from selenium import webdriver
  class InstaBot:
     
  
      def __init__(self):
             self.driver = webdriver.Firefox()
             self.driver.implicitly_wait(10)
             self.driver.get(&quot;https://www.instagram.com/randomusername/&quot;)
         
     def get_follower(self, username, pw):
         self.driver.find_element_by_xpath(&quot;/html/body/div[1]/section/main/div/header/section/ul/li[3]/a&quot;)\
             .click()
        
        
         self.driver.find_element_by_xpath(&quot;//input[@name=\&quot;username\&quot;]&quot;)\
             .send_keys(username)
        
         self.driver.find_element_by_xpath(&quot;//input[@name=\&quot;password\&quot;]&quot;)\
             .send_keys(pw)
   
         self.driver.find_element_by_xpath('//button[@type=&quot;submit&quot;]')\
             .click()
   
         self.driver.find_element_by_xpath(&quot;/html/body/div[1]/section/main/div/div/div/section/div/button&quot;)\
             .click()
   
         self.driver.find_element_by_xpath(&quot;/html/body/div[1]/section/main/div/header/section/ul/li[2]/a&quot;)\
             .click()
  
         
         follow = self.driver.find_elements_by_xpath(&quot;/html/body/div[5]/div/div/div[2]/ul/div/li[3]/div/div[2]&quot;)
  
         i =1
  
         for follower in follow:
              if(i !=1):
                  self.driver.find_elements_by_xpath(&quot;/html/body/div[5]/div/div/div[2]/ul/div/li[1]/div/div[3]&quot;)\
                      .click()
  
                  i += 1   
        
  
  
         
   
   
  my_bot = InstaBot()
  my_bot.get_follower('username', 'pw')
  </code></pre>