场景:chrome密码登录时弹出的密码提示框,遮挡了要点击的元素,导致元素不可点击
解决方案:
初始化Chrome的时候加参数,不弹出密码框
添加这两个参数即可:
"credentials_enable_service": False,
"profile.password_manager_enabled": False
代码如下:
options =webdriver.ChromeOptions()
options.add_experimental_option("prefs", {
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True,
"credentials_enable_service": False,
"profile.password_manager_enabled": False
})
options.add_experimental_option("excludeSwitches", ['enable-automation'])
browser = webdriver.Chrome(chrome_options=options)