How to close the chrome window that is opened by applying the code webbrowser.open?
<p>I imported webbrowser in the very beginning of this file. The whole code was like this in the below.</p>

<pre><code>import time 
import webbrowser

break_times = 3
break_count = 0


print ("Program started at: " + time.ctime())
while break_count &lt; break_times :
    time.sleep(5)
    webbrowser.open("https://www.youtube.com/watch?v=m69d-KNi2Q0")
    break_count = break_count + 1
</code></pre>

<p>But I am stuck here. The code opens my chrome browser but I couldn't close it using code. Any suggestion would be helpful.</p>

<p>Thank you.</p>

<p>Try using <code>selenium</code>.</p>

<pre><code>import time
from selenium import webdriver

break_times = 3
break_count = 0

browser = webdriver.Firefox()

print("Program started at: " + time.ctime())
while break_count &lt; break_times:
    time.sleep(5)
    browser.get("https://www.youtube.com/watch?v=m69d-KNi2Q0")
    break_count = break_count + 1

browser.close()
</code></pre>

python import