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

相关推荐
中冕—霍格沃兹软件开发测试5 小时前
边界值分析:功能测试中的精度利器
人工智能·功能测试·科技·测试工具·appium·bug
Wpa.wk8 小时前
自动化测试-鼠标+键盘操作 - Actions高级控件
java·开发语言·测试工具·自动化·计算机外设·actions·高级控件
我的xiaodoujiao8 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 32--开源电商商城系统项目实战--如何区分登录状态
python·学习·测试工具·pytest
The Electronic Cat9 小时前
树莓派安装nginx
运维·chrome·nginx
mike041210 小时前
Eclipse+maven+selenium自动化测试开发环境搭建
selenium·eclipse·maven
suoyue_zhan10 小时前
GBase 8s V8.8 安装部署实践指南
前端·数据库·chrome
嘻哈baby11 小时前
Let‘s Encrypt免费证书与HTTPS配置完全指南
chrome·网络协议·https
我的xiaodoujiao12 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 33--基础知识 8--切换窗口句柄
python·学习·测试工具·pytest
卓码软件测评20 小时前
第三方高校软件课题验收测试机构:【使用Apifox测试gRPC服务步骤和技巧】
网络·测试工具·测试用例
搬山境KL攻城狮1 天前
记-SPA单页面应用Chrome自动翻译导致中文错别字问题
前端·chrome