Window keeps closing after running selenium

前端 未结 3 1497
遥遥无期
遥遥无期 2021-01-25 16:43

Everytime I run this code the window opens blank and then loads the required page for about 1 second before closing.

from selenium import webdriver

driver = w         


        
3条回答
  •  梦谈多话
    2021-01-25 17:37

    One of the best possible workarounds is to set Sleep(), so that the browser doesn't close:

    import time 
    
    driver.get('https://www.google.com')
    time.sleep(3000)  #this makes browser not to close.
    

    Additional reading https://selenium-python.readthedocs.io/waits.html

提交回复
热议问题