title: Selenium instagram followers throws stale element reference
body: <p>I'm in the middle of collecting data for Machine Learning, and I am struggling with scraping one of the social network pages for data. I'm good until the 12th follower, and then it crashes.</p>
  
  <p>The method, driver.findElement(By.xpath... stops working on the 13th element, even though it's scrolling. Could anyone point me to the reason for it not being visible? This is what I came up until now:</p>
  
  <pre><code>import org.openqa.selenium.*;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.chrome.ChromeOptions;
  import org.openqa.selenium.interactions.Actions;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  public class Testing {
  
  public static ChromeOptions options;
  public static WebDriver driver;
  
  public static void setup() {
      System.setProperty("webdriver.chrome.driver", "resources/Drivers/chromedriver.exe");
      options = new ChromeOptions();
      driver = new ChromeDriver(options);
      driver.get("https://www.instagram.com/accounts/login/");
  }
  
  public static void login() throws Exception {
      String name = "xxxxxx";
      String password = "xxxxxxx";
      Thread.sleep(2000);
      driver.findElement(By.name("username")).sendKeys(name);
      driver.findElement(By.name("password")).sendKeys(password);
      driver.findElement(By.tagName("form")).click();
      WebDriverWait wait = new WebDriverWait(driver, 15);
      wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("See All")));
     driver.get(String.format("https://www.instagram.com/officialrickastley/"));
      driver.findElement(By.partialLinkText("follower")).click();
  try {
      Thread.sleep(3000);
      for (int j = 1; j &lt; 1000; j += 11) {
          System.out.println("j " + j);
          WebElement element = driver.findElement(By.xpath(("/html/body/div[4]/div/div[2]/ul/div/li[" + (j) + "]/div/div[2]/div[1]/div/div/a")));
          Actions actions = new Actions(driver);
          actions.moveToElement(element);
          actions.perform();
          for (int i = 1; i &lt; 12; i++) {
              System.out.println("user: " + i + " " + driver.findElement(By.xpath(("/html/body/div[4]/div/div[2]/ul/div/li[" + (i + j) + "]/div/div[2]/div[1]/div/div/a")))
                      .getAttribute("title"));
              Thread.sleep(300);
          }
      }
  } catch (Exception e) {
      e.printStackTrace();
  } finally {
      driver.close();
    }
     }
  }
  </code></pre>