Title: Python Selenium Detach Option Not Working
Tags: python;selenium;selenium-webdriver
Question: I want to write a Python script using Selenium and Chrome where Selenium won't close the Chrome browser when the script finishes. From doing a bunch of googling, it looks like the standard solution is to use the detach option. But when I run the following script:
```import selenium
from selenium import webdriver

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

driver = webdriver.Chrome(options=chrome_options)
driver.get(&quot;https://www.google.com/&quot;)
```
It opens up Chrome, goes to Google's homepage, and  then closes the browser. It's not throwing any errors.
Any idea why it's not working? I'm using the latest version of Google Chrome on Windows 10, and I've got the latest version of the selenium module installed. I couldn't find anything online that said the experimental detach option no longer existed. And I double checked the API, and it looks like it's the right syntax.

Comment: Where is driver path in your code ?

Comment: @AndersSchneiderman u want the browser to not be closed when your script is done, right?

Comment: If you don't specify the driver path, it uses a default path -- and it was finding the driver just fine. I also tried adding the driver name, and I got the same results

Comment: Sorry, forgot to mention: I tried both chrome_options as well as options. Same result.

Comment: have you tried setting `chrome_options=chrome_options`, rather than `options=chrome_options`?

Here is the accepted answer: This code worked perfectly for me using : ```selenium-wire``` , hope it works for you
```from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option(&quot;detach&quot;, True)

driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
driver.get(&quot;https://www.google.com/&quot;)
```


Here is another answer: I discovered another way to go: start Chrome in remote debugging mode, then connect to it. That way, not only does the browser stay open, but you can also use your existing Chrome profile so you can take advantage of any sites your cookies allow you to access without having to log in every time you run the script.
Here's what you need to do if you're on Windows 10:

Start Google Chrome up remotely, pointed towards your existing user profile and the port you want to use:

```cd &quot;C:\Program Files (x86)\Google\Chrome\Application&quot;
chrome.exe -remote-debugging-port=9014 --user-data-dir=&quot;%LOCALAPPDATA%\Google\Chrome\User Data&quot;
```

In your python script, connect to the  local port that this version of Chrome is running on:

```import selenium
from selenium import webdriver

from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option(&quot;debuggerAddress&quot;, &quot;localhost:9014&quot;)
driver = webdriver.Chrome(options=chrome_options)

driver.get(&quot;https://github.com/&quot;)
```

Comment for this answer: a great alternative, but i suggest u check this: https://pypi.org/project/selenium-wire/ for future projects with selenium

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:05/28/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><selenium><selenium-webdriver>', 'Title': 'Python Selenium Detach Option Not Working', 'ViewCount': 1351, 'id': 67738780, 'user_AboutMe': None, 'user_AccountId': 12868695.0, 'user_DisplayName': 'Anders Schneiderman', 'user_Reputation': 23.0, 'user_Views': 1.0, 'user_id': 9307975.0}}