Chrome 在python selenium中禁用保存密码弹出

holgip5t  于 2023-06-03  发布在  Go
关注(0)|答案(2)|浏览(287)

这是我的代码

def __init__(self,username,password):
    self.options = webdriver.ChromeOptions()
    self.options.add_argument("--no-sandbox")
    self.options.page_load_strategy = 'eager'
    self.options.add_experimental_option("excludeSwitches", ['enable-automation'])
    self.options.add_argument("--disable-blink-features=AutomationControlled")
    #self.options.add_argument('--headless')
    self.options.add_argument('--disable-gpu')
    self.options.add_argument('window-size=1280,720')
        #lchrome = webdriver.Chrome(driver,options=options)
        #lchrome.minimize_window()

        #un = username
        #up = password
    time.sleep(3)
    self.lchrome = webdriver.Chrome(driver,options=self.options,)

我如何禁用恼人的保存密码弹出?请帮帮忙。谢谢你

cl25kdpy

cl25kdpy1#

你可以用下面的方法来做。
从Selenium导入webdriver

chrome_opt = webdriver.ChromeOptions()
prefs = {"credentials_enable_service": False,
     "profile.password_manager_enabled": False}
chrome_opt.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=chrome_opt, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("https://google.com")
u2nhd7ah

u2nhd7ah2#

在Chrome/MsEdge中禁用保存密码弹出窗口的一个快速解决方案是使用隐身模式。以下是您可以使用selenium grid的功能:

{
  "browserName": "chrome",
  "goog:chromeOptions": {
    "excludeSwitches": [
      "enable-automation"
    ],
    "useAutomationExtension": false,
    "args": [
      "--incognito",  # for Chrome
      "--inprivate",  # for MsEdge
      "--save-page-as-mhtml"
    ]
  }
}

相关问题