【web自动化】指定chromedriver以及chrome路径

selenium自动化,指定chromedriver,以及chrome路径
===对应这篇文章,可以点击查看,详情===

python 复制代码
from selenium import webdriver

def get_driver():
    # 获取配置对象
    option = webdriver.ChromeOptions()
    option.add_experimental_option("detach", True)
    # 去掉自动化标识
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    option.add_argument('--disable-blink-features=AutomationControlled')
    # 关闭保存密码弹窗
    prefs = {}
    prefs['credentials_enable_service'] = False
    prefs['profile.password_manager_enabled'] = False
    option.add_experimental_option('prefs', prefs)
    # 驱动chromedriver路径
    driver_path = 'X:\Program Files (x86)\Chrome\ChromeCore\chromedriver_win32\chromedriver.exe'

    # 指定 Chrome 浏览器的可执行文件路径
    option.binary_location = r'X:\Program Files (x86)\Chrome\ChromeCore\ChromeCore.exe'

    driver = webdriver.Chrome(options=option, executable_path=driver_path)
    driver.implicitly_wait(10)
    time.sleep(1)
    driver.get('https://www.baidu.com')
    # return driver

get_driver()
相关推荐
测试_AI_一辰2 小时前
AI Agent 评测最隐蔽的坑-记忆
人工智能·算法·ai·自动化·ai编程
学习和思考3 小时前
非自动化专业如何自学PLC?我的6个月学习路线图
笔记·学习·自动化·学习方法
m0_525724724 小时前
Jenkins共享库实现流水线复用
自动化·k8s·devops
Black蜡笔小新6 小时前
从智慧社区到雪亮工程:国标GB28181公网平台EasyCVR如何构建视频“一张网”?
人工智能·自动化·easycvr
梦想的旅途26 小时前
企业微信自动化实战:客户资料自动修改与备注同步
运维·自动化·企业微信
梦想的旅途26 小时前
企业微信自动化实战:客户通讯录备份与关系自动迁移
运维·自动化·企业微信
xian_wwq7 小时前
【学习笔记】Loop Engineering,从手动提示到目标驱动自动化-13/16
笔记·学习·自动化
ii_best8 小时前
iOS 投屏ios群控鹰眼中控系统安装指南|电脑端 + TestFlight + 开发者模式实操
ios·自动化·按键精灵
刚入门的大一新生9 小时前
Linux-Linux基础开发工具3-自动化创建make/Makefile
linux·运维·自动化
独隅19 小时前
GitHub Actions 自动化运维实战:CI/CD 流水线一体化效果展示
运维·自动化·github