os.system taskkill in for-loop

Viewed 120

I have a script that opens a specified URL in chrome, shows it for 10 seconds before closing Chrome and then waits another 10 seconds before opening the same URL again (some memory training for the persons I want to use it for).

Now the problem is that Chrome closes the first time, but then the second time in the loop it doesn't close at all. No errors or warnings. I need this loop to run three times.

Am I missing something here?

import webbrowser
import os
import time

url = '<url>'
chrome_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe'

for i in range(3):
    webbrowser.get(chrome_path).open_new(url)
    time.sleep(10)
    os.system("taskkill /f /t /im chrome.exe")
    time.sleep(10)
0 Answers
Related