自动检测并更新driver文件,提高selenium代码的稳定性
Project description
介绍
浏览器的更新和driver文件的版本异常,经常是影响代码稳定性的一个原因,而每次driver文件的更新也是比较繁杂的工作,此次的safe-driver意在帮助维护driver的稳定性
作用
safe-driver导入后,可替换selenium的webdriver,使用方式和方法同selenium的webdriver 当启动浏览器driver文件出错时,程序将自动下载并更新浏览器驱动,并重新返回driver,提高代码的稳定性
导入
from SafeDriver.drivers import driver
from SafeDriver.drivers import option
使用
此操作同selenium的webdriver.Chrome()
driver = driver()
driver.get("https://www.baidu.com")
放入options参数
首先确定导入option配置参数 使用同selenium的ChromeOptions,可直接添加,添加后,无需再次写入到driver中
from SafeDriver.drivers import option
option.add_argument('--headless')
路径和系统配置
路径和系统保存在option中,配置需要导入option
from SafeDriver.drivers import option
option.pypath = 'xxx' # python的根目录路径
option.os_ = 'xxx' # 当前使用的操作系统
注意事项:
1、option.os_:参数不赋值,则视为自动查找当前操作系统 2、option.pypath:参数不赋值,则视为自动查到python路径(目前自动查找操作系统仅支持windows系统,linux和mac用户请手动配置option.pypath属性)
目前仅支持chrome浏览器,暂未更新其他浏览器
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file SafeDriver-1.2.0.tar.gz.
File metadata
- Download URL: SafeDriver-1.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
279d26ead6649a2b455d588ff00bf74c01b00a3e92fe5edc59657744934145d5
|
|
| MD5 |
388bf573fdc569b604855e1e06a464d1
|
|
| BLAKE2b-256 |
a6cc0f19c65f5957d82c758e7948ca55eac3b35b82e99871a226c12c3eb9501c
|
File details
Details for the file SafeDriver-1.2.0-py3-none-any.whl.
File metadata
- Download URL: SafeDriver-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ed05b92308f53b76512b87b0afce8a56195eaa5ef2d848a38e51188f9d48202
|
|
| MD5 |
f7562d960c4121e5087db0ad8eecb29f
|
|
| BLAKE2b-256 |
7c5693146968575683672f2e62f193d8f2f2f272808bc26015126e2a44240d72
|