Python Selenium: How to check whether the WebDriver did quit()?

前端 未结 7 1201
一个人的身影
一个人的身影 2021-02-08 12:26

I want to control whether my WebDriver quit but I can\'t find a method for that. (It seems that in Java there\'s a way to do it)

from selenium impor         


        
7条回答
  •  不要未来只要你来
    2021-02-08 12:53

    suggested methods above didn't work for me on selenium version 3.141.0

    dir(driver.service) found a few useful options 
    
    driver.session_id   
    driver.service.process
    driver.service.assert_process_still_running()
    driver.service.assert_process_still_running 
    

    I found this SO question when I had a problem with closing an already closed driver, in my case a try catch around the driver.close() worked for my purposes.

    try:
        driver.close()
        print("driver successfully closed.")
    except Exception as e:
        print("driver already closed.")
    

    also:

    import selenium
    help(selenium)
    

    to check selenium version number

提交回复
热议问题