这是我的代码。
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()
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到此错误,
['/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]
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我一直收到错误。我尝试更改路径以授予它访问权限,但仍然出现错误。也许我做错了什么,但我无法弄清楚。
| 归档时间: |
|
| 查看次数: |
6079 次 |
| 最近记录: |