title: How to distinguish between a new window and a new tab in Selenium
body: <p>I want to know if there is any way to distinguish between a new window and a new tab, natively in Selenium.</p>
  <p>On my test page there are buttons to open a page in the same window, a new window, or a new tab.</p>
  <p>I know how to switch to the new window or tab using window handles, but I cannot distinguish between the two. How do I know if the button opened the link in a new tab, and not a new window?</p>
  <p>i.e. in pseudocode (need code for <code>openedInNewWindow()</code> and <code>openedInNewTab()</code>)</p>
  <pre><code>click(newTabButton);
  if (openedInSameWindow()) {
      Log.Error(&quot;Link opened in same window :(&quot;);
  } else if (openedInNewWindow()) {
      Log.Error(&quot;Link opened in new window :(&quot;);
  } else if (openedInNewTab()) {
      Log.Success(&quot;Link opened in new tab :)&quot;);
  } else {
      Log.Error(&quot;Link didn't open anything :(&quot;);
  }
  </code></pre>