selenium 选项 chrome_options

当前环境:

Windows 10 + Python 3.7 + selenium 3.141.0 + Google Chrome 115.0.5790.110 (64 位)

一种方法:

python 复制代码
from selenium import webdriver


if __name__ == '__main__':
    # chrome 选项配置
    chrome_options = webdriver.ChromeOptions()
    # 设置无界面浏览
    # chrome_options.add_argument('--headless')
    # 忽略证书报错
    chrome_options.add_argument('ignore-certificate-errors')
    # 取消chrome受自动控制提示
    chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
    # 关掉密码弹窗
    prefs = {"": "", "credentials_enable_service": False, "profile.password_manager_enabled": False}
    chrome_options.add_experimental_option("prefs", prefs)
    # Chrome.exe 路径
    chrome_options.binary_location = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
    # chromedriver.exe 路径
    ChromedriverPath = r'.\chromedriver.exe'
    driver = webdriver.Chrome(ChromedriverPath, options=chrome_options)

    # 打开百度
    driver.get('https://www.baidu.com')

另外一种方法:

python 复制代码
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


if __name__ == '__main__':
    # chrome 选项配置
    options = Options()
    # 设置无界面浏览
    # options.add_argument('--headless')
    # 忽略证书报错
    options.add_argument('ignore-certificate-errors')
    # 取消chrome受自动控制提示
    options.add_experimental_option("excludeSwitches", ['enable-automation'])
    # 关掉密码弹窗
    prefs = {"": "", "credentials_enable_service": False, "profile.password_manager_enabled": False}
    options.add_experimental_option("prefs", prefs)
    # Chrome.exe 路径
    options.binary_location = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
    # chromedriver.exe 路径
    ChromedriverPath = r'.\chromedriver.exe'
    driver = webdriver.Chrome(ChromedriverPath, options=options)

    # 打开百度
    driver.get('https://www.baidu.com')

参考:

selenium关闭左上方Chrome 正受到自动测试软件的控制的提示 - 简书

https://www.cnblogs.com/yangjintao/p/10599868.html

相关推荐
daopuyun26 分钟前
技术最前沿|最新版软件安全测试工具Fortify 安全规则库26.1更新内容
测试工具·安全
HAPPY酷9 小时前
Linux `shutdown` 命令速查:安全关机与重启
linux·chrome·安全
tjuarch10 小时前
技术备忘录:华硕 A43S (Ubuntu) 插电限频故障修复
linux·chrome·ubuntu·技术备忘录
为你奋斗!11 小时前
Playwright 录屏功能启用离线安装依赖pywin32 pillow
开发语言·chrome·python·语言模型·迁移学习
Wpa.wk13 小时前
IDE中配置Git常见操作
ide·经验分享·git·测试工具
海特伟业1 天前
蒸汽阀门内漏检测仪-疏水器内漏检测仪-让蒸汽阀门疏水器内部泄漏由被动抢修转变为主动预防
测试工具
tiandyoin1 天前
Brave(Chrome)浏览器设置选项中文注解
前端·chrome·设置·brave
gameboy0311 天前
网络爬虫学习:应用selenium获取Edge浏览器版本号,自动下载对应版本msedgedriver,确保Edge浏览器顺利打开。
爬虫·学习·selenium
进击切图仔1 天前
执行 shell 脚本 5 种方式对比
前端·chrome
小鹿软件办公1 天前
谷歌将在2026年第二季度为ARM64 Linux设备推出Chrome
linux·chrome