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

相关推荐
咖啡の猫35 分钟前
Shell脚本-for循环应用案例
前端·chrome
Zuckjet13 小时前
V8 引擎的性能魔法:JSON 序列化的 2 倍速度提升之路
前端·chrome·v8
甄超锋13 小时前
python sqlite3模块
jvm·数据库·python·测试工具·django·sqlite·flask
John_ToDebug14 小时前
Chromium base 库中的 Observer 模式实现:ObserverList 与 ObserverListThreadSafe 深度解析
c++·chrome·性能优化
中草药z18 小时前
【自动化测试】Selenium详解-WebUI自动化测试
前端·功能测试·selenium·自动化·html·web·测试
RPA+AI十二工作室1 天前
亚马逊店铺绩效巡检_影刀RPA源码解读
chrome·python·rpa·影刀
zzc9211 天前
TLSv1.2协议与TCP/UDP协议传输数据内容差异
网络·测试工具·安全·wireshark·ssl·密钥·tlsv1.2
Jinkxs1 天前
告别“测试滞后”:AI实时测试工具在敏捷开发中的落地经验
人工智能·测试工具·敏捷流程
秃了也弱了。2 天前
WireShark:非常好用的网络抓包工具
网络·测试工具·wireshark
shuangrenlong2 天前
ubuntu更新chrome版本
linux·chrome·ubuntu