【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()
相关推荐
小堃学编程7 小时前
Selenium自动化测试工具安装和使用(PyCharm)
selenium·测试工具·自动化
waterHBO9 小时前
修改 vscode 左侧导航栏的文字大小 (更新版)
ide·chrome·vscode·编辑器
鱼与宇9 小时前
WebSphere(WAS)
前端·chrome
优质&青年9 小时前
Devops自动化运维---py基础篇一
运维·自动化
无声旅者9 小时前
n8n:解锁自动化工作流的无限可能
ai·自动化·oneapi·ai大模型·n8n
梓䈑10 小时前
【Linux系统】命令行参数 和 环境变量(含内建命令介绍)
linux·运维·chrome
smart199811 小时前
自动化生产线,IT部署一站式解决方案-Infortrend KS私有云安全,一机多用
运维·自动化
引量AI12 小时前
如何用AI高效运营1000+Tiktok矩阵账号
人工智能·矩阵·自动化·tiktok矩阵·海外社媒
JIANGHONGZN13 小时前
Ethernet/IP转DeviceNet网关:驱动大型矿山自动化升级的核心纽带
自动化·工业控制·工业自动化·ethernet/ip·协议网关·devicenet
幽络源小助理16 小时前
OA工程自动化办公系统 – 免费Java源码
java·运维·自动化