0 votes
1 view
in Devops and Agile by (19.8k points)

I set up a python code to run Selenium chromedriver.exe. At the end of the run, I have browser.close() to close the instance. (browser = webdriver.Chrome()) I believe it should release chromedriver.exe from memory (I'm on Windows 7). However, after each run, there is one chromedriver.exe instance remain in the memory. I hope there is a way I can write something in python to kill the chromedriver.exe process. Obviously browser.close() doesn't do the work. Thanks.

1 Answer

0 votes
by (63.4k points)

This answer will depict, how to properly dispose of the web-driver in C#

If you want to use a 'proper' mechanism that should be used to 'tidy up' after running ChromeDriver you should use IWebDriver.Dispose();

I usually implement IDisposable on the class that is dealing with IWebDriver

public class WebDriverController : IDisposable

{

   public IWebDriver Driver;

    public void Dispose(){

        this.Driver.Dispose();

    }

}

and use it like:

using (var controller = new WebDriverController())

{

//code goes here

}

 Hope this helps!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...