【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()
相关推荐
xy345327 分钟前
谷歌Lighthouse安装指南(Chrome扩展程序可视化操作)
前端·chrome·测试工具·lighthouse
2601_9622845038 分钟前
利用Python语言实现实验室自动化
python·自动化·数据采集·labview·科学计算
隐擎fox39 分钟前
网络传输中的 DNS 泄漏成因剖析与 Python 自动化检测排查实战
python·网络协议·自动化·dns·ip/tcp
智塑未来9 小时前
自动化立体库工业无线通信:AGV、AMR、RGV、穿梭车、无人叉车、堆垛机全覆盖
运维·自动化
flower_drop10 小时前
基于 WebUSB 与 CDP:在浏览器端实现 Android 设备通信与无证书抓包实践
android·chrome·测试工具·adb·bug·edge浏览器
志栋智能12 小时前
运维超自动化的变更管理实践
运维·自动化
每天被AI救一次16 小时前
WorkBuddy 会议自动化实战:从腾讯会议转写到待办系统的完整链路(附全套提示词)
运维·自动化·腾讯会议
林墨聊AIGC17 小时前
AI视频怎么做跳舞的动作效果:从入门到精通的舞蹈动画制作指南
大数据·人工智能·自动化·aigc·音视频
chuntian_tester18 小时前
AI自动化第3步【用例设计】
人工智能·测试工具·ai·自动化
此冬歌咏19 小时前
自动化服务器运维监控系统(python+shell)
linux·运维·服务器·开发语言·python·自动化