Selenium Webdriver session

Tags
Registered Posts: 1

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?

Answers

  • Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,270 Dataiker
    edited July 2024

    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

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.