0

I know using driver.quit() I can close all browser instances opened in a particular session. Now if my script has opened few browser instances in checking invalid login scenarios which remains opened, now if I run new script for valid login scenario and logout, this time I want my previously opened browser also to close when I use driver.quit()

But it's not happening, it is closing only browser opened in current session, not all those browser which was opened by selenium in older session. Is it possible to achieve my scenario? I heard about webDriver.Dispose() but I guess this is not applicable in current version of Selenium as it's showing error for me. Please suggest who I can achieve my scenario.

Shoaib Akhtar
  • 1,393
  • 5
  • 17
  • 46

1 Answers1

1

The current driver can only affect the windows opened by that driver. It sounds like in your invalid login script, you aren't using driver.quit() or the windows aren't getting closed properly. Once this happens, you can't use Selenium to fix it. You would need to use some sort of OS-based script to kill those open windows. For Windows, you can use a batch file that contains taskkill /f /im chromedriver.exe, etc. for each browser or a PowerShell script.

JeffC
  • 22,180
  • 5
  • 32
  • 55