这是我试图运行的代码:
from selenium import webdriver
driver = webdriver.Chrome("C:\Users\mathe\pythonProject\test\drivers\chromedriver.exe")
我收到此错误:
C:\Python27\python.exe C:/Users/mathe/pythonProject/main.py
Traceback (most recent call last):
File "C:/Users/mathe/pythonProject/main.py", line 2, in <module>
driver = webdriver.Chrome("C:\Users\mathe\pythonProject\test\drivers\chromedriver.exe")
File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
答案 0 :(得分:1)
无法发表评论...
请仔细检查可执行文件的路径。 如果仍然显示错误,请将chromedriver.exe放在.py文件所在的文件夹中。这样,您不必编写完整路径,只需将其留空即可:
from selenium import webdriver
web=webdriver.Chrome()