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

前端 未结 7 982
一个人的身影
一个人的身影 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:51

    How about executing a driver command and checking for an exception:

    import httplib, socket
    
    try:
        driver.quit()
    except httplib.CannotSendRequest:
        print "Driver did not terminate"
    except socket.error:
        print "Driver did not terminate"
    else:
        print "Driver terminated"
    

提交回复
热议问题