title: Selenium Basic VBA focus on new tab that is opened by Click
body: <p>I'm working on the Selenium Basic Wrapper for Excel VBA, but upon clicking  a button that opens a new tab, I am unable to get the selenium web-driver to switch focus onto the new tab that is opened, and to close the original tab.. Believe this should be achievable using the Java Selenium, but is there any way to do it through the Selenium Basic wrapper on excel VBA? </p>
  
  <p>Have tried using bot.switchtopreviouswindow/nextwindow to no avail, Selenium does not even seem to detect the new tab/window opened as an existing window, also tried using switchwindow using title to no avail...</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
      Dim bot As New ChromeDriver
      Dim merchant As String
      Dim promocode As Object
      Dim number As Long
      Dim test As Object
      Dim testnumber As Integer
  
      lastColumn = Sheets("Merchants").Range("B" &amp; Rows.Count).End(xlUp).Row
  
      For i = 2 To lastColumn
  
          bot.Get (Sheets("Merchants").Range("B" &amp; i).Value)
          merchant = Sheets("Merchants").Range("A" &amp; i).Value
  
          For Each promocode In bot.FindElementByClass("main_vouchers").FindElementsByClass("c")
  
              number = Right(promocode.Attribute("id"), 6)
  
              If IsEmpty(promocode) = True Then Exit For
  
  
              promocode.FindElementByClass("go").Click
  
              #This is the part I have problems with as after click, original page re-directs to another page, and new tab opens (which is the place  I want focus on). Also, I need the original tab closed so that Chrome doesn't end up opening too many tabs due to the loop running. Appreciate the help!
  
          Next promocode
  
      Next i
  
  End Sub
  </code></pre>
  
  <p>Just need Selenium to switch focus onto newly opened tab and for old/original tab to be closed..</p>