Mik*_*ann 3 python selenium selenium-chromedriver
我目前正在从 chrome 102 切换到 104 Beta(因为 103 对于我使用 python - selenium 脚本的用例有一个未修复的错误)
我安装了 Chrome Beta 104 + 104 chrome 驱动程序。当我启动脚本时,它识别出它是 104 驱动程序,但驱动程序本身会在旧 chrome 路径中搜索 chrome.exe 应用程序:
现在搜索的位置:C:\Program Files\Google\Chrome\Application\chrome.exe
应在何处搜索:C:\Program Files\Google\Chrome Beta\Application\chrome.exe
有没有一些简单的方法可以更改 beta chrome 驱动程序搜索 exe 的二进制路径?如果我可以将一些简单的东西放入我的 python 脚本中,那就太好了。
在这种情况下,您应该在 Options 类中使用 binary_location 指定 selenium 必须在哪里查找 chrome 执行器。
试试这个:
假设您的 chromedriver.exe 和 python 文件位于同一文件夹中,否则您还必须指定 chromedriver.exe 的路径。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
options = Options()
options.binary_location = r'C:\Program Files\Google\Chrome Beta\Application\chrome.exe'
browser = webdriver.Chrome(options = options, service = Service("chromedriver.exe"))
browser.get(your_url)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2063 次 |
| 最近记录: |