How to close the browser after completing a download?

前端 未结 3 1191
一向
一向 2021-01-04 08:28

How to make browser closed after completing download?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver         


        
3条回答
  •  误落风尘
    2021-01-04 08:57

    You may want to use the below piece of code right before you close the browser.

    time.sleep(5)# Gives time to complete the task before closing the browser. You may increase the seconds to 10 or 15,basically the amount of time required for download otherwise it goes to the next step immediately.

    browser.quit()
    

提交回复
热议问题