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
''''python
def closedriver():
global drivername
drivername.quit()
global driveron
driveron=False
''''
this function "closedriver" uses a global variable named "drivername" and global bool variable named "driveron",you may just pass a current driver as parameter but
NOTE: driveron must be global to store the state of driver being 'on' or 'off'.
''''python
def closedriver(drivername):
global driveron
try:
drivername.quit()
except:
pass
driveron=False
''''
and when you start a new driver, just use a check
global driveron
if not driveron:
driver=webdriver.Chrome()