title: Switching tabs not working in Selenium Webdriver
body: <p>I wrote this code in C# and it's not working for me.</p>
  
  <p>Second url is still opening in the first tab, although I switched tabs and updated handle.</p>
  
  <pre><code>// open first page in first tab
  string firstPageUrl = "http://google.com";
  driver.Navigate().GoToUrl(firstPageUrl);
  // getting handle to first tab
  string firstTabHandle = driver.CurrentWindowHandle;
  
  // open new tab
  Actions action = new Actions(driver);
  action.SendKeys(OpenQA.Selenium.Keys.Control + "t").Build().Perform();
  string secondTabHandle = driver.CurrentWindowHandle;
  
  // open second page in second tab
  driver.SwitchTo().Window(secondTabHandle);
  string secondPageUrl = "http://bbc.com";
  driver.Navigate().GoToUrl(secondPageUrl); // FAILED, page is opened in first tab -.-
  Thread.Sleep(2000); // slow down a bit to see tab change
  
  // swtich to first tab
  action.SendKeys(OpenQA.Selenium.Keys.Control + "1").Build().Perform();
  driver.SwitchTo().Window(firstTabHandle);
  Thread.Sleep(1000);
  action.SendKeys(OpenQA.Selenium.Keys.Control + "2").Build().Perform();
  </code></pre>
  
  <p>I'm using latest Chrome driver.</p>
  
  <p>Any ideas? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is not duplicate. I am not opening links here, I want to navigate to URL I've provided. Also, I am using <code>CurrentWindowHandle</code> as suggested, but it is not working for me.</p>