您应该 自己启动浏览器 ,然后告诉selenium,您已经通过 传递特殊通道id 启动了它。像这样:
from random import randrangechannel_id = "%032x" % randrange(16**32)from subprocess import Popen# HERE YOU PASS onLY THOSE PARAMETERS YOU WANT (i.e. without --disable-*)# BUT YOU MAY NEED --dom-automation FOR SOME ROUTINESchrome = Popen(" ".join([ PATH_TO_CHROME_EXE, "--no-first-run", "--dom-automation", ("--testing-channel="NamedTestingInterface:%s"" % channel_id),]))try: from selenium.webdriver.chrome.service import Service chromedriver_server = Service(PATH_TO_CHROMEDRIVER, 0) chromedriver_server.start() from selenium.webdriver import Remote driver = Remote(chromedriver_server.service_url, {"chrome.channel": channel_id, "chrome.noWebsiteTestingDefaults": True}) driver.get(MY_WEBPAGE) # DO YOUR WORKfinally: chromedriver_server.stop() driver.quit()chrome.kill()chrome.wait()


