title: How to open a new window on a browser using Selenium WebDriver for python?
body: <p>I am attempting to open a new tab OR a new window in a browser using selenium for python.  It is of little importance if a new tab or new window is opened, it is only important that a second instance of the browser is opened.</p>
  
  <p>I have tried several different methods already and none have succeeded.</p>
  
  <ol>
  <li><p>Switching to a window that does not exist with hopes that it would then open a new window upon failure to locate said window:</p>
  
  <p><code>driver.switch_to_window(None)</code></p></li>
  <li><p>Iterating through open windows (although there is currently only one)</p>
  
  <pre><code>for handle in driver.window_handles:
      driver.switch_to_window(handle)
  </code></pre></li>
  <li><p>Attempting to simulate a keyboard key press</p>
  
  <pre><code>from selenium.webdriver.common.keys import Keys
  driver.send_keys(Keys.CONTROL + 'T')
  </code></pre></li>
  </ol>
  
  <p>The problem with this one in particular was that it does not seem possible to send keys directly to the browser, only to a specific element like this:</p>
  
  <pre><code>driver.find_element_by_id('elementID').send_keys(Keys.CONTROL + 'T')
  </code></pre>
  
  <p>However, when a command such as this is sent to an element, it appears to do absolutely nothing.  I attempted to locate the topmost HTML element on the page and send the keys to that, but was again met with failure:</p>
  
  <pre><code>driver.find_element_by_id('wrapper').send_keys(Keys.CONTROL + 'T')
  </code></pre>
  
  <p>Another version of this I found online, and was not able to verify its validity or lack thereof because I'm not sure what class/module which needs importing</p>
  
  <pre><code>act = ActionChains(driver)
  act.key_down(browserKeys.CONTROL)
  act.click("").perform()
  act.key_up(browserKeys.CONTROL)
  </code></pre>
  
  <p>Something very similar with different syntax (I'm not sure if one or both of these is correct syntax)</p>
  
  <pre><code>actions.key_down(Keys.CONTROL)
  element.send_keys('t')
  actions.key_up(Keys.CONTROL)
  </code></pre>