-1

How can i validate if I have another browser opened on my python code using selenium. i create a function to call the webdrive

but the browser have not open before called

def OpenDriver():
    if not drive:   
        drive = webdriver.Chrome(ChromeDriverManager().install())
        return drive
    else:
        return drive
pass    

def site():
    navega().get("https://www.google.com/")
pass

1 Answers1

0

You actually want to check if drive variable exists.
So you should change from

if not drive:

to

if drive in locals() or drive in globals():

See more explanations about checking local and global variables existance here

Prophet
  • 32,350
  • 22
  • 54
  • 79