Python selenium keep browser open

前端 未结 2 807
说谎
说谎 2020-12-17 23:50

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, tha

2条回答
  •  再見小時候
    2020-12-18 00:10

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

    In your case add :

    from selenium.webdriver.chrome.options import Options
    chrome_options = Options()
    chrome_options.add_experimental_option("detach", True)
    

    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

提交回复
热议问题