一直报TypeError: object of type 'WebElement' has no len()
下面是我的代码
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
from selenium.webdriver.common.by import By
web = webdriver.Chrome(service=Service('D:/chromedriver_win32/chromedriver.exe'))
web.get('https://www.zhihu.com/signin?next=%2F')
action = ActionChains(web)
password_log = web.find_element(By.XPATH,value='//form/div/div[@role="button"][2]')
password_log.click()
usernameTag = web.find_element(By.NAME, 'username')
action.move_to_element(usernameTag)
action.send_keys(usernameTag,'1479709179')
# action.send_keys(usernameTag,'1479709179')
passwordTag = web.find_element(By.NAME,'password')
action.move_to_element(passwordTag).send_keys('123456')
submit = web.find_element(By.CLASS_NAME,'SignFlow-submitButton')
action.move_to_element(submit)
action.click(submit)
web.quit()
明面上看不到调用了len()方法哇,对象没有len()方法,还没看到调用的地方
把action.send_keys(usernameTag,'1479709179')
改成action.send_keys_to_element(usernameTag, '1479709179')
就不报错了,但是不能把值输入进去