title: How to wait responds in Selenium when using loop nodejs?
body: <pre><code>const webdriver=require('selenium-webdriver'); // selenium webdriver
  const chromedriver=require('chromedriver'); // chrome driver
  const by=webdriver.By;
  const untill=webdriver.until;
  
  const driver=new webdriver.Builder().forBrowser('chrome').build();
  driver.get('https://www.example.com/sell-my-cell-phone/sell-my-samsung/');
  driver.findElements(by.className('LaptopBox')).then((rst)=&gt;{
      rst.forEach((el)=&gt;{
          driver.wait(untill.elementsLocated(by.tagName('a')))
          let btn=el.findElement(by.tagName('a'));
          btn.click();
          console.log("abc")
      });
  });
  </code></pre>
  
  <p>i'm trying this code. but it gave me this error after printing console log.</p>
  
  <blockquote>
    <p>UnhandledPromiseRejectionWarning: StaleElementReferenceError: stale
    element reference: element is not attached to the page document</p>
  </blockquote>
  
  <p>in my html like following.</p>
  
  <pre><code>&lt;ul id="LaptopBox"&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href="#"&gt;anchor one&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href="#"&gt;anchor two&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href="#"&gt;anchor three&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>