python - Python 从 selenium 启动 Chromedriver 在 IDLE 中有效,但在 Visual Studio Code 中无效
问题描述
下面是我的代码,当我通过 powershell/cmd/IDLE 运行它时,它会完美地启动 chromedriver。但是,当我尝试通过 Visual Studio 代码运行它时,我收到以下文本。
“selenium.common.exceptions.WebDriverException:消息:'chromedriver.exe' 可执行文件需要在 PATH 中。请参阅https://sites.google.com/a/chromium.org/chromedriver/home ”
#SELENIUM INFO#
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
#SELENIUM INFO#
import os
print(os.getcwd())
driver = webdriver.Chrome(os.getcwd() +'\\chromedriver.exe')
我右键单击代码并单击“在终端中运行 Python 文件”但是我发现我什至无法使用终端来 cd 到文件结构内部更深的代码。
我的文件结构是“G:\Quality User Data\Malahy\Projects\AQE Interfaces>”
但是chrome驱动和python文件一起存放在更深的目录中。
"G:\Quality User Data\Malahy\Projects\AQE Interfaces\AQE Interface\Logistics\Repack"
我开始认为这是 Visual Studio Code 的错误,而不是我的程序。
解决方案
推荐阅读
- emacs - 通过 org-sbe 将 org-mode 属性传递给源代码块
- javascript - Javascript没有按预期反应
- python - 在 python 正则表达式中,为什么 (h)* 和 (h)+ 不能产生相同的结果?
- google-maps-api-3 - 使用带有 Flutter 的 Google Maps 初始单击标记后如何更新 InfoWindowText?
- c# - HttpClient.SendAsync 显然崩溃或阻塞?
- matlab - 未分配一个或多个输出参数
- javascript - 节点文件系统模块重命名方法
- reactjs - 如何隐藏 MUI React ListItem?
- excel - 匹配两个表中的两个单元格并检查条件是否为真
- python - 此代码必须使用 for 循环打印每个其他字符