title: Selenium in Javascript - Having trouble looping through multiple sites: sites.forEach(site => { driver.get(site).sleep(1000).then( do stuff... ) });
body: <p>I think I setup my driver.get(site) calls wrong as they're all executing at the same time. I'm trying to have selenium visit a site, do some logic, pause for a bit, then start over by visiting a different site. Unfortunately, this is all happening at the same time right now, causing the browser to redirect to the next site in the array as soon as the page loads.</p>
  
  <pre><code>let webdriver = require("selenium-webdriver");
      let sites = [
      'https://www.site1.com'
      , 'https://www.site2.com'
      , 'https://www.site3.com'
  ];
  let driver = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();
  sites.forEach(site =&gt; {
      driver.get(site).then(x =&gt; { 
          //   perform a mixture of send keys, clicks, and a mandatory delay
          Promise.all([
              promise1
              , promise2
              , driver.sleep(1000)
          ]).then(y =&gt; {
  
          }).catch(err =&gt; {
  
          })
      })
  })
  </code></pre>