Home > database >  Close webdriver when stop test execution from visual studio in specflow
Close webdriver when stop test execution from visual studio in specflow

Time:08-26

I would like to close webdriver from task manager, when I stop test execution in visual studio. Normally I could use AfterTestRun to close the driver, but, when I click over stop button in visual studio meanwhile test execution is running AfterTestRun isn't execute, so web driver is still open.

CodePudding user response:

You can't do this, as Visual Studio/Test Explorer is killing the test execution process when you stop the execution. No code is executed then and there is also no place where you could put some code that gets executed.

I have a command line script that kills all the processes when I press a shortcut.

You can kill a process via command line on Windows this way:

taskkill /f /im chromedriver.exe

This kills all processes with the name chromedriver.exe.

  • Related