Python从硒启动Chromedriver在IDLE中有效,但在Visual Studio Code中无效

时间:2019-02-26 19:22:29

标签: python selenium selenium-chromedriver os.path

下面是我的代码,当我通过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的错误,而不是我的程序。

0 个答案:

没有答案