How to properly close a Selenium WebDriver instance in python? How to properly close a Selenium WebDriver instance in python? selenium selenium

How to properly close a Selenium WebDriver instance in python?


Without commenting on your code design:

In order to close a driver instance, use driver.close() or driver.quit() instead of your driver.stop_client().

The first one closes the the browser window on which the focus is set.The second one basically closes all the browser windows and ends the WebDriver session gracefully.


Use

chrome_options.quit()

Obs.: Im pretty sure you should not use testcases like that... "while 1"? so you test will never end?

I guess you should setup your testes in TestCases and call the TheSuite to teste all your testcases and give you one feedback about whant pass or not, and maybe setup one cronjob to keep calling it by time to time.

Here one simple example mine using test cases with django and splinter (splinter is build on top of selenium)

https://github.com/Diegow3b/python-django-basictestcase/blob/master/myApp/tests/test_views.py