title: Open Multiple URLs concurrently in same browser Selenium (JAVA)
body: <p>I know how to open multiple URLs concurrently on different browsers (<a href="https://stackoverflow.com/questions/26380378/selenium-parallel-testing-on-multiple-browsers-java">Selenium parallel testing on multiple browsers (JAVA)</a>). However my requirement is to open multiple URLs in different tabs but using only one browser. Is there a way to do it?<br>
  This is what i tried, but I am unable to open a new tab.</p>
  
  <pre><code>//mainclass
  public static void main(String a[])
  {
      WebDriver wd = BrowserClass.getWebDriver();
      Thread t1 = new Thread(new ParallelOpenUrl(wd));
      t1.setName("https://www.google.com");
      Thread t2 = new Thread(new ParallelOpenUrl(wd));
      t2.setName("https://www.manageengine.com");
      Thread t3 = new Thread(new ParallelOpenUrl(wd));
      t3.setName("https://www.zoho.com");
      t1.start();
      t2.start();
      t3.start();
  }
  
  public class ParallelOpenUrl implements Runnable 
  {
      private WebDriver wd = null;
      public ParallelOpenUrl(WebDriver wd)
      {
          this.wd = wd;
      }
      @Override
      public void run() 
      {
          try
          {
              BrowserClass.openTab(wd);
              Thread.sleep(1000);
              wd.switchTo().window(BrowserClass.getCurrentTab());
              wd.get(Thread.currentThread().getName());
          }
          catch(Exception e)
          {
              e.printStackTrace();
          }   
          finally
          {
              wd.close();
          }
      }
  }
  
  
  //BrowserClass
  public static String getCurrentTab(WebDriver wd)
  {   
      Set&lt;String&gt; allTabs = wd.getWindowHandles();
      ArrayList&lt;String&gt; tabs = Lists.newArrayList(allTabs);
      return tabs.get(tabs.size()-1);
  }
  public static WebDriver getWebDriver()
  {
      private WebDriver wd = null;
      if(wd == null)
      {
          System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe");
          wd = new ChromeDriver();
      }
      return wd;
  }
  public static void openTab() throws Exception
  {
      Robot rb = new Robot();
      rb.keyPress(KeyEvent.VK_CONTROL);
      rb.keyPress(KeyEvent.VK_T);
      rb.keyRelease(KeyEvent.VK_CONTROL);
      rb.keyRelease(KeyEvent.VK_T);       
  }
  </code></pre>
  
  <p>The browser opens the tabs concurrently. But only one tab is active at a time. That is, only after tab 1 has finished loading google.com, tab 2 starts loading zoho.com. </p>