Skip to content
Advertisement

Python selenium keep browser open

I am using selenium to open some browser windows for marketing reasons. I simply open my marketing sources, login via selenium and start working.

The problem is, that after the code is executed selenium closes the window.

All solutions havent helped much so far.

I have 13 browser windows atm., which look like this:

JavaScript

The closest solution which I found is adding this at the end of my script, but somehow it will only keep 5 windows open, than close 5 windows and open next 5 new windows:

JavaScript

I just want that selenium keeps all browser windows open, until I close them manually.

Advertisement

Answer

If you want chrome and chromedriver to stay open, you have to use the ‘detach’ option when starting chromedriver.

In your case add :

JavaScript

before you pass in the options to the browser

JavaScript

Or you can run the code in debug mode with breakpoint at the end and when it pauses ‘kill’ the program and take over the browser if you want to, but this works in IDE only.

EDIT – added the import for clarity

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement