Selenium Webdriver session

Options
marie790
marie790 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?

Tagged:

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    edited July 17
    Options

    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

Setup Info
    Tags
      Help me…