I'm trying to log into Facebook Marketplace from Selenium. The email address is populating as expected. The password field is not being recognized.
The error:
File "C:Usersjsmithfb.py", line 18, in
password.send_keys(password)
TypeError: object of type 'WebElement' has no len()
My code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
import time
username = 'myemail'
password = 'mypassword'
#OpenBrowser
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://facebook.com/")
#Logging
email = driver.find_element_by_id('email')
password = driver.find_element_by_xpath('//*[@id="pass"]')
#facebook username input
email.send_keys(username)
#facebook password input
password.send_keys(password)
I have tried using find_element_by_name()
and find_element_by_id()
(and the plural of both) in addition to the xpath above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…