XSMMDoctor
Junior Member
- Jun 7, 2026
- 114
- 27
@baldeepo IndexError means there is no second tab at that moment, so either popup blocked, tab not opened yet, or chrome crashed before selenium can see the handle. Dont switch with window_handles[1] directly, save old handles first and wait for new one.
But if it works without chrome profile and crashes only with profile/extensions, then the tab code is not the real problem imo. Your profile is most likely locked or one extension is killing renderer. Make a fresh selenium-only chrome profile and load only needed extension, dont use your daily chrome profile. Also close all chrome.exe from task manager before running, even one background process can mess it up.
Code:
old_tabs = driver.window_handles
driver.execute_script("arguments[0].click();", pin)
WebDriverWait(driver, 15).until(lambda d: len(d.window_handles) > len(old_tabs))
new_tab = list(set(driver.window_handles) - set(old_tabs))[0]
driver.switch_to.window(new_tab)
But if it works without chrome profile and crashes only with profile/extensions, then the tab code is not the real problem imo. Your profile is most likely locked or one extension is killing renderer. Make a fresh selenium-only chrome profile and load only needed extension, dont use your daily chrome profile. Also close all chrome.exe from task manager before running, even one background process can mess it up.