I have made a Windows Forms app to host my GUI for running selenium tests.
When the user presses the "run test" button, it launches an instance of chromedriver and runs the selected selenium test.
However, let's say that while the test is running, the user decides they want to stop the test, or simply not have the entire test run.
I have a button on the form that calls FixtureTearDown() in case this were to happen. FixtureTearDown is simply:
if (_driver != null) _driver.Quit();
However, if you DO press this "stop test" button, the driver closes, but the selenium test keeps executing the script as if the webdriver were still open, which then throws errors (because it can't find elements because the driver is closed, duh) and causes my Windows Forms app to crash.
So, is there a way to gracefully halt the running of a selenium script? Thanks in advance for the help, and i apologize if this is a dumb question, i am still new to selenium and c# in general.
driver.quit()
. Which browser are you using? Are you sure your button click event quits the driver?