title: driver.close() doesn't close the current tab in selenium
body: <p>I have a selenium webautomation program for tradingview. It all stays in one tab but when I open a new tab/link which it than switches to and which I than want to close after that, it closes the original tab. It looks like this:</p>
  <pre><code>for i in range(1, 1001):
  input_ = '/html/body/div[8]/div/div[4]/table/tbody/tr[x]/td[1]/div/div[2]/a' 
  list_input_ = list(input_) 
  list_input_[44] = str(i)  
  input_ = ''.join(list_input_)
  stock = driver.find_element_by_xpath(input_) 
  stock.click()
  time.sleep(5)
  driver.close() 
  print(input_)
  if i &gt; 9:
      break 
  </code></pre>
  <p>The stock = driver.find_element_by_xpath(input_) and stock.click() opens the new tab/link to the left. But than driver.close() closes the tab I was previously in. I want it close the tab that it just opened and that I'm currently in. Which it supposed to do. It also seems like that none of the selenium commands work on this newly opened tab and only work on the original tab.</p>
  <p>The copied element of the link it opens looks like this:<code>&lt;a class=&quot;tv-screener__symbol apply-common-tooltip&quot; href=&quot;https://www.tradingview.com/symbols/NASDAQ-STAF/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;STAF&lt;/a&gt;</code></p>
  <p>Did I do something wrong here? Thanks in advance</p>