I am using selenium with python to open chrome and the Adblock gets installed every time I load it. In addition to the tab that I want to use a "Thank you for Installing adblock" tab opens which is very annoying. To close the tab I tried this
chld = driver.window_handles[1]
driver.switch_to.window(chld)
driver.close
Closing the driver like this does not allow me to continue on the main tab as I get this error
selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
So to deal with this I thought maybe I can edit the adblock crx files to not open the new tab but I don't know how and what changes I can make. Here is folder for the adblock files that can be edited.
Try the following patch to focus on the current tab after closing the "Adblock" tab:
chld = driver.window_handles[1]
driver.switch_to.window(chld)
driver.close
current_tab=driver.window_handles[0]
driver.switch_to.window(current_tab)
driver.get("https://www.yahoo.com")
time.sleep(2)
Let me know if this worked for you