【发布时间】:2018-10-11 07:11:31
【问题描述】:
我刚刚使用 Python 启动了 Selenium。而且我正面临属性错误问题。
已安装 Python 3.6.5 并安装了最新的 selenium 包(selenium-3.11.0)
还在环境中添加了脚本和 Python 文件夹路径 变量:PATH。
下载了 chromedriver.exe 并添加了 相应的文件路径到环境变量中。
但是在运行下面的代码时:
from selenium import webdriver
driver = webdriver.Chrome("E:\Selenium\chromedriver_win32\chromedriver.exe")
它抛出以下错误:
C:\Users\Sooraj\venv\firstpgm\Scripts\python.exe C:/Users/Sooraj/PycharmProjects/Selenium/First.py
Traceback (most recent call last):
File "C:/Users/Sooraj/PycharmProjects/Selenium/First.py", line 2, in
<module>
driver=webdriver.Chrome("E:\Selenium\chromedriver_win32\chromedriver.exe")
AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
Process finished with exit code 1
尝试了 Stack Overflow 中提供的所有其他解决方案,例如卸载和重新安装 Python 以及升级 selenium。但没有任何帮助。
代码使用 PyCharm IDE 运行,但使用 IDLE 运行时运行良好。
可以在 Sitepackages -> selenium -> webdriver 下找到 firefox、chrome、safari、phantomjs、android 等文件夹。但不知道为什么它仍然显示“Webdriver has no attribute chrome”
附上以上截图。在 webdriver 下显示没有模块 chrome()
任何帮助将不胜感激。
【问题讨论】:
标签: python selenium selenium-webdriver