Skip to main content

基于阿里源开发的WebDriver管理工具

Project description

WebDriverManager CN

Python Version PyPI Version License Downloads

基于国内镜像源的 WebDriver 自动管理工具

简体中文


📖 简介

WebDriverManager CN 是一个基于 阿里云镜像源华为云镜像源 的 WebDriver 自动下载管理工具,是 webdriver_manager 的国内镜像版本。

✨ 特性

  • 🚀 自动下载 - 自动匹配浏览器版本并下载对应的 WebDriver
  • 🇨🇳 国内加速 - 支持阿里云、华为云镜像源,下载速度快
  • 💾 智能缓存 - 自动缓存已下载的驱动,避免重复下载
  • 🧹 自动清理 - 可配置自动清理过期的驱动文件
  • 🔄 灵活切换 - 支持多镜像源切换,保证可用性
  • 🎯 跨平台 - 支持 Windows、MacOS、Linux

📦 安装

使用 pip 安装

pip install webdrivermanager_cn

升级到最新版本

pip install -U webdrivermanager_cn

🚀 快速开始

ChromeDriver 使用示例

方式一:使用阿里云镜像源(推荐)

from webdrivermanager_cn import ChromeDriverManagerAliMirror

driver_path = ChromeDriverManagerAliMirror().install()

方式二:使用华为云镜像源

from webdrivermanager_cn import ChromeDriverManagerHuaweiMirror

driver_path = ChromeDriverManagerHuaweiMirror().install()

方式三:手动切换镜像源

from webdrivermanager_cn import ChromeDriverManager

driver = ChromeDriverManager()
driver.set_ali_mirror()  # 切换为阿里源(默认)
# driver.set_huawei_mirror() # 切换为华为源

driver_path = driver.install()

Geckodriver (Firefox) 使用示例

使用阿里云镜像源

from webdrivermanager_cn import GeckodriverManagerAliMirror

driver_path = GeckodriverManagerAliMirror().install()

使用华为云镜像源

from webdrivermanager_cn import GeckodriverManagerHuaweiMirror

driver_path = GeckodriverManagerHuaweiMirror().install()

手动切换镜像源

from webdrivermanager_cn import GeckodriverManager

driver = GeckodriverManager()
driver.set_ali_mirror()  # 切换为阿里源(默认)
# driver.set_huawei_mirror() # 切换为华为源

driver_path = driver.install()

🛠️ 配置选项

日志配置

import os
import logging

# 开启日志功能(默认关闭)
os.environ['WDM_LOG'] = 'true'

# 设置日志级别(默认为 INFO)
os.environ['WDM_LOG_LEVEL'] = str(logging.INFO)

自定义 Logger

from webdrivermanager_cn.core.log_manager import set_logger
import logging

# 使用自定义 logger
my_logger = logging.getLogger('my_custom_logger')
set_logger(my_logger)

缓存管理

import os

# 设置缓存清理时间(单位:天,默认为 5 天)
# 会自动删除 5 天前下载的旧版本 WebDriver
os.environ['WDM_CACHE_TIME'] = '5'

📊 支持的浏览器

浏览器 Windows MacOS Linux
Chrome
Firefox

💡 如需支持其他浏览器,欢迎提交 Issue


🤝 贡献

欢迎贡献代码、提出建议或报告问题!

  1. Fork 本仓库
  2. 创建您的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 提交 Pull Request

如果您发现了新的国内镜像源,欢迎提交 Issue 或 PR!


📄 许可证

本项目基于 Apache-2.0 协议开源。


⚠️ 免责声明

本项目仅供自动化测试工具使用,请勿用于非法用途。对于任何使用者的行为,本项目及作者不承担任何责任。

本项目依赖以下第三方服务,如有相关问题,会积极推进解决,但无法保证完全解决:


📮 联系方式

如果在使用过程中遇到任何问题,欢迎提交 Issue


💡 开发背景

作者是一名测试开发工程师,在自动化测试工作中使用 webdriver_manager 解决了 Chrome 频繁更新导致 ChromeDriver 无法使用的问题。

然而,2023年中期,ChromeDriver 官方修改了发布方式,导致国内大部分镜像源无法正确同步新版本(停留在 114 版本)。虽然阿里云镜像已经完成了新版同步,但原有的下载方式已经无法适配。

因此,作者研究源码后决定重新开发一个基于国内镜像源的 WebDriver 管理工具,帮助无法访问 GitHub 的团队和个人继续使用自动化测试。


如果这个项目对您有帮助,请给一个 ⭐️ Star!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webdrivermanager_cn-2.4.3-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file webdrivermanager_cn-2.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for webdrivermanager_cn-2.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 51832e42f5e4a4cd9c7d776924c23a4bc1b0f9d3a739bb37d8299d4ff28e12e8
MD5 82c0a29220906fe5121c1cf8202a0cd4
BLAKE2b-256 c69f1db7840211b8315f2b645438dc3096730c44b151cb96b5da1a75a8af87d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page