title: Switch window on Selenium
body: <p>I am using Selenium with PhantomJS in Python.
  I need to open a new window and control it.</p>
  
  <p>For testing purposes, I'm doing so:</p>
  
  <pre><code>from selenium import webdriver
  driver = webdriver.PhantomJS()
  
  driver.get('http://www.google.com.br')
  handle = driver.execute_script('return window.open("http://www.pudim.com.br/", "any", "height = 450, width = 800, menubar=yes,scrollbars=yes,toolbar=yes,location=no,resizable=yes");')
  driver.switch_to.window(driver.window_handles[1])
  print(driver.current_url)
  </code></pre>
  
  <p>The above code works partially. The URL printed on the last message is <code>about: blank</code> as would be expected is <code>http://www.pudim.com.br/</code></p>