I am using python 3.7 + selenium + geckodriver.exe + firefox 70.0.1x64,I know driver.quit()
could close firefox window,but in some situation I can not quit firefox totally,I do not know why,this is my code:
from selenium import webdriver
import time
def func1():
driver = webdriver.Firefox()
i = 0
while True:
try:
if i > 10 and driver is not None:
driver.quit()
driver = None
print('quit success')
i += 1
print(i)
time.sleep(1)
except KeyboardInterrupt:
if driver is not None:
driver.quit()
driver = None
print('keyboard quit success')
if __name__ == '__main__':
func1()
With this code,there are tow ways to close firefox window:
1-wait 10 seconds.
2-use Ctrl+C.
Then I test method 1
python test1.py
When firefox winodw showed,I notice there are 6 process in task manager,like this
Then I wait 10 seconds,everything is fine,6 process is gone,like this:
Then I test method 2
I press Ctrl+C in 10 seconds,result like this:
You can see that there are still 5 process alive,only 1 process is gone,I do not know why,Can anyone help me?Thanks a lot!