Selenium Webdriver session

marie790
Level 1
Selenium Webdriver session

Hello,

I opened a WebDriver Session using Selenium but when I ran the recipe there was an exception and the recipe failed which means that the code where I quit the session hasn't been executed. Now I have multiple Webdriver sessions open but I don't know how to retrieve them and close them. Is there someone who can help with that?

0 Kudos
1 Reply
AlexT
Dataiker

Hi @marie790 ,

You should always try and except in your code and close the driver before exiting the code even where there is an exception something like:

try:
    
    # Do something with the driver here
    
except Exception as e:
    # Handle the error
    print(f"An error occurred: {e}")
    
finally:
    # Close the driver
    driver.quit()

 

TO close existing driver session you need to kill the PIDs from CLI

ps -ef | grep chromedriver
kill the PIDS or you can try  pkill chromedriver

Thanks

0 Kudos