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

相关推荐
402 Payment Required5 小时前
serv00 ssh登录保活脚本-邮件通知版
运维·chrome·ssh
炫彩@之星7 小时前
Chrome书签的导出与导入:步骤图
前端·chrome
李三岁_foucsli8 小时前
js中消息队列和事件循环到底是怎么个事,宏任务和微任务还存在吗?
前端·chrome
Hacker_seagull17 小时前
Chrome安装代理插件ZeroOmega(保姆级别)
前端·chrome
代码的乐趣17 小时前
支持selenium的chrome driver更新到137.0.7151.68
chrome·selenium·测试工具
有风南来1 天前
算术图片验证码(四则运算)+selenium
自动化测试·python·selenium·算术图片验证码·四则运算验证码·加减乘除图片验证码
程序员三藏2 天前
如何使用Jmeter进行压力测试?
自动化测试·软件测试·python·测试工具·jmeter·测试用例·压力测试
编程乐学(Arfan开发工程师)2 天前
42、响应处理-【源码分析】-浏览器与PostMan内容协商完全适配
java·spring boot·后端·测试工具·lua·postman
集成显卡2 天前
PlayWright | 初识微软出品的 WEB 应用自动化测试框架
前端·chrome·测试工具·microsoft·自动化·edge浏览器