Chromedriver closing after test

10,861

The service will stop once your script ends due to the code here.

If you want chrome and chromedriver to stay open afterward, you can add the detach option when starting chromedriver:

from selenium.webdriver import ChromeOptions, Chrome
opts = ChromeOptions()
opts.add_experimental_option("detach", True)
driver = Chrome(chrome_options=opts)
Share:
10,861
Sevvy325
Author by

Sevvy325

Updated on June 15, 2022

Comments

  • Sevvy325
    Sevvy325 almost 2 years

    So my understanding is that calling driver.quit or close is the the proper way to close the driver and associated window.

    However when running my tests, it seems that even without calling driver.quit and instead calling pass, that the window still closes.

    I'm using python with unittest test cases excuted via pytest. I've also run standard unitests via Pycharm. In all scenarios, the browser closes as described. I want the browser to stay open to where I can debug tests. I could just call sleep(9000) but that seems dumb.

    Furthermore, the browser stays open when commenting out quit on some machines, but not on others with the same chromedriver, Chrome version, and code.

    Analyzing the chromedriver logs, it seems it registers a QuitAll command, but I have no idea where it could be getting it from. Could the pyc file not be overwritten?

    Code for quit:

    def tearDown(self):
        pass
        # self.driver.quit()