title: How to open a new tab in the same browser by using Selenium WebDriver with Java?
body: <p>I can open a new window with Selenium WebDriver by using Java and JavaScript. I am using Firefox. The code is as follows:</p>
  
  <pre><code>WebDriver driver = new FirefoxDriver();
  JavascriptExecutor jse = (JavascriptExecutor)driver;
  jse.executeScript("function createDoc(){var w = window.open(); w.document.open(); w.document.write('&lt;h1&gt;Hello World!&lt;/h1&gt;'); w.document.close();}; createDoc();");
  </code></pre>
  
  <p>How can I open a new tab in the same browser by using WebDriver (Selenium 2)?</p>