这是我的代码。ImportError:无法导入名称'webdriver''
import sys
print (sys.path)
from selenium import webdriver
from selenium.webdriver.common.by import BY
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'email'
passwordStr = 'password'
browser = webdriver.Chrome()
browser.get('http://website.com')
username = browser.find_element_by_xpath('//*[@id="did-ui"]/div/div/section/section/form/section/div[1]/div/label/span[2]/input')
username.send_keys(usernameStr)
password = browser.find_element_by_xpath('//*[@id="did-ui"]/div/div/section/section/form/section/div[2]/div/label/span[2]/input')
password.send_keys(passwordStr)
nextButton = browser.find_element_by_xpath('//*[@id="did-ui"]/div/div/section/section/form/section/div[3]/button[1]')
nextButton.click()
当我运行它,我得到这个错误,
['/Users/austinjohnson/Desktop/streakscraper', '/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
Traceback (most recent call last):
File "/Users/austinjohnson/Desktop/streakscraper/login.py", line 6, in <module>
from selenium import webdriver
ImportError: cannot import name 'webdriver'
[Finished in 0.1s with exit code 1]
[cmd: ['/usr/local/bin/python3', '-u', '/Users/austinjohnson/Desktop/streakscraper/login.py']]
[dir: /Users/austinjohnson/Desktop/streakscraper]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
我想不通,为什么我总是收到一个错误。我试图改变路径以使其可以访问,但我仍然遇到错误。也许我做错了什么,但我无法弄清楚。
雅我已经检查过了。没有名为硒的文件。 – tin