My question is that I excepted main tab to be closed after the execution of last of code as the focus should be on that tab after i closed the second tab. But instead I got this error, selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found see the code below with comments
driver = webdriver.Chrome(path)
actions_chain = ActionChains(driver)
driver.get(url)
time.sleep(10)
title_click = driver.find_element_by_xpath('//div[@data-testid = "listing-card-title"]')
actions_chain.click(title_click).perform()
#using action_chains instance in order to click
#that click takes me to the description page in the second tab
driver.switch_to.window(driver.window_handles[1])
#switch the browser focus to second tab
driver.close()
#closing the second tab
#After closing the second tab, I only left with one main tab and the browser focus should be on that one main tab without explicitly shifting to that tab
driver.close()
so the main tab also gets closed.