Selenium安装WebDriver(含116/117/118/119)

本文指导如何检查浏览器版本,选择并下载对应Chromedriver,解压后将其放置到Chrome安装目录。通过PythonSelenium示例验证chromedriver安装是否成功,包括登录百度的操作。
部署运行你感兴趣的模型镜像

1、确认浏览器的版本

在浏览器的地址栏,输入chrome://version/,回车后即可查看到对应版本
在这里插入图片描述

2、找到对应的chromedriver版本

2.1 114及之前的版本可以通过点击下载chromedriver,根据版本号(只看大版本)下载对应文件
在这里插入图片描述

2.2 116版本通过点击下载chromedriver,便可直接下载压缩包

2.3 117/118/119版本通过点击进入到 Chrome for Testing availability
可以看到117 Stable 稳定版本以及更高版本的测试版
在这里插入图片描述
点击Stable,选择对应的驱动下载即可。
在这里插入图片描述
3、解压chromedriver文件,放置chrome的安装目录下
4、确认chromedriver是否安装成功及解决方式
在pycharm里执行以下代码块,能打开访问浏览器,即为成功。

from selenium import webdriver
 
chromedriver_path = r"C:\Users\AppData\Local\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver_path)
 
 
# 登录百度
def main():
    driver.get("https://baidu.com/")
 
 
if __name__ == '__main__':
    main()

在这里插入图片描述

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

lxng@lxng-MS-7D31:~/ChatGPT-API-Scanner$ python3 src/main.py 📂 Opening database file github.db 🌍 Opening Chrome ... Traceback (most recent call last): File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/driver_finder.py", line 67, in _binary_paths output = SeleniumManager().binary_paths(self._to_args()) File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/selenium_manager.py", line 54, in binary_paths return self._run(args) File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/selenium_manager.py", line 131, in _run raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: /home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --language-binding python --output json; code: 65 {'code': 65, 'message': 'error decoding response body', 'driver_path': '', 'browser_path': ''} The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/lxng/ChatGPT-API-Scanner/src/main.py", line 338, in <module> main( File "/home/lxng/ChatGPT-API-Scanner/src/main.py", line 281, in main leakage.login_to_github() File "/home/lxng/ChatGPT-API-Scanner/src/main.py", line 66, in login_to_github self.driver = webdriver.Chrome(options=options) File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__ super().__init__( File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 51, in __init__ if finder.get_browser_path(): File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/driver_finder.py", line 47, in get_browser_path return self._binary_paths()["browser_path"] File "/home/lxng/.local/lib/python3.10/site-packages/selenium/webdriver/common/driver_finder.py", line 78, in _binary_paths raise NoSuchDriverException(msg) from err selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location lxng@lxng-MS-7D31:~/ChatGPT-API-Scanner$
最新发布
12-13
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

生而为虫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值