This question already has an answer here:
I am trying to keep the chrome browser open after selenium finishes executing my test script. I want to re-use the same window for my second script to run.
This question already has an answer here:
I am trying to keep the chrome browser open after selenium finishes executing my test script. I want to re-use the same window for my second script to run.
I know what to do in WATIR(Ruby language), I am writing the code below, So it might give you the clue what to do with your language
This given below line is important, If you can re-write this line your language(python),then you may prevent from closing chrome browser
Browser window closes when your Chrome webdriver instance variable is garbage collected. If you want to avoid this even when your script finishes executing, you can make it global. I.e.:
Explanation: A
selenium.webdriver.Chrome
class instance contains an instance of aService
class. The latter has a__del__
method which is called when the instance is being destructed during garbage collection process. The method in turn stops the service and causes Chrome browser window to close.This also explains why some users don't observe this behavior. I suspect that this is because they have Chrome webdriver instance variable at file scope, not inside a function.
This should be as simple as not calling driver.quit() at the end of your test case. You should be left with the chrome window in an opened state.