All codes I have tried are outdated. The best I have found so far will immediately disconnect when I try to perform any webdriver action.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import subprocess
import os
driverPath = ChromeDriverManager().install()
subprocess.Popen(["start","chrome","--remote-debugging-port=9089","--user-data-dir=" + os.getcwd() + "/chromeProfile",],shell=True)
options = Options()
options.add_argument("--start-maximized")
options.add_experimental_option("debuggerAddress", "127.0.0.1:9089")
service = Service(executable_path=driverPath)
driver = webdriver.Chrome(service=service,options=options)
-
Either navigate to where chrome.exe is or add to PATH
-
Run CMD:
chrome.exe –remote-debugging-port=9089
–user-data-dir=”D:…chrome_profile”
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_experimental_option("debuggerAddress", "localhost:9089")
driver = webdriver.Chrome(options=options)