Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromedriver closing after test

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()
like image 646
Sevvy325 Avatar asked Apr 25 '17 13:04

Sevvy325


Video Answer


1 Answers

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)
like image 152
Lucas Tierney Avatar answered Sep 19 '22 23:09

Lucas Tierney