'How do I store the ID of the current tab and switch to this tab?

I opened a completely new window and three tabs.

driver.get('link1')
driver.switch_to.new_window('tab')
driver.get('link2')
wait.sleep(2)
driver.switch_to.new_window('tab')
driver.get('link3')

How can I store the id of the tab1, tab2, tab3, so I can programmatically switch between them?

I tried this:

  original_window = driver.current_window_handle


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source