title: Python Selenium: How to use debugger_address option in chrome driver for Remote Debugging?
body: <p>I want to launch my selenium chrome web driver to current existing session.</p>
  
  <p>So I am trying to connect via remote debugging instead of starting a new instance.</p>
  
  <p><a href="https://sites.google.com/a/chromium.org/chromedriver/help/operation-not-supported-when-using-remote-debugging" rel="noreferrer">https://sites.google.com/a/chromium.org/chromedriver/help/operation-not-supported-when-using-remote-debugging</a></p>
  
  <p>So what I did is launched chrome at 127.0.0.1:6813 by cmd.</p>
  
  <pre><code>C:\Program Files (x86)\Google\Chrome\Application&gt;chrome.exe '127.0.0.1:6813'
  </code></pre>
  
  <p>A new instance of chrome started.</p>
  
  <p>Now in my code I added debugger_address="127.0.0.1:6813" using chrome options.</p>
  
  <pre><code>chrome_options.debugger_address="127.0.0.1:6813"
  </code></pre>
  
  <p>But my Spyder IDE gives following error:</p>
  
  <pre><code>runfile('C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py', wdir='C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi')
  Traceback (most recent call last):
  
    File "&lt;ipython-input-9-77e28441ef9f&gt;", line 1, in &lt;module&gt;
      runfile('C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py', wdir='C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi')
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
      execfile(filename, namespace)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)
  
    File "C:/Users/Gupta Niwas/Downloads/Programming/Projects/Mi/temp7.py", line 22, in &lt;module&gt;
      browser = webdriver.Chrome(chrome_options=chrome_options,executable_path=cpath)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
      desired_capabilities=desired_capabilities)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
      self.start_session(capabilities, browser_profile)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 245, in start_session
      response = self.execute(Command.NEW_SESSION, parameters)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in execute
      self.error_handler.check_response(response)
  
    File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  
  WebDriverException: unknown error: cannot connect to chrome at 127.0.0.1:6813
  from chrome not reachable
    (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17134 x86_64)
  </code></pre>
  
  <p>Full code:</p>
  
  <pre><code>import pyautogui
  from time import sleep
  from selenium import webdriver
  
  from selenium.webdriver.common.keys import Keys
  
  from selenium.common.exceptions import NoSuchElementException,TimeoutException
  from selenium.webdriver.common.action_chains import ActionChains
  
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.common.by import By
  
  fpath="C:/Users/Gupta Niwas/Downloads/Softwares/Browsers/Drivers/geckodriver-v0.21.0-win64/geckodriver.exe"
  cpath="C:/Users/Gupta Niwas/Downloads/Softwares/Browsers/Drivers/chromedriver_win32/chromedriver.exe"
  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_argument("--incognito")
  chrome_options.add_argument("start-maximized")
  chrome_options.debugger_address="127.0.0.1:6813"
  
  #browser = webdriver.Firefox(executable_path=fpath)
  browser = webdriver.Chrome(chrome_options=chrome_options,executable_path=cpath)
  #browser.execute_async_script("function(){(function(a){document.body.appendChild(a);a.setAttribute('href', 'http://google.com');a.dispatchEvent((function(e){e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);return e;}(document.createEvent('MouseEvents'))))}(document.createElement('a')));}")
  browser.get('https://youngeinsteins.com/')
  
  pyautogui.hotkey('ctrl','t')
  
  WebDriverWait(browser,100).until(EC.visibility_of_element_located((By.CSS_SELECTOR,'html.gtie9.js.flexbox.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths.dk_fouc body.home.page-template-default.page.page-id-15 div.subscribe-popup-wrap div.subscribe-popup div.close svg.icon-cross polygon')))
  cross=browser.find_element_by_css_selector('html.gtie9.js.flexbox.canvas.canvastext.webgl.no-touch.geolocation.postmessage.no-websqldatabase.indexeddb.hashchange.history.draganddrop.websockets.rgba.hsla.multiplebgs.backgroundsize.borderimage.borderradius.boxshadow.textshadow.opacity.cssanimations.csscolumns.cssgradients.no-cssreflections.csstransforms.csstransforms3d.csstransitions.fontface.generatedcontent.video.audio.localstorage.sessionstorage.webworkers.applicationcache.svg.inlinesvg.smil.svgclippaths.dk_fouc body.home.page-template-default.page.page-id-15 div.subscribe-popup-wrap div.subscribe-popup div.close svg.icon-cross polygon')
  cross.click()
  </code></pre>