from selenium import webdriver
import time
br = webdriver.Chrome()
br.get('https://onlineservices.tin.egov-nsdl.com/etaxnew/tdsnontds.jsp')
login_form = br.find_element_by_link_text('CHALLAN NO./ITNS 281').click()
radio = br.find_elements_by_css_selector("input[type='radio'][value='0021']") [0].click()
tan = br.find_elements_by_css_selector("input[type='text'][name='TAN']")[0].click()
time.sleep(2)
tan.send_keys("something")
一切正常except send_keys
无法在文本字段中填写文本并得到错误
Attribute error: 'NoneType' object has no attribute 'send_keys'
答案 0 :(得分:4)
click()
不返回任何值,您无法单击它。保留从find_element
返回的元素,并使用它单击并发送密钥
tan = br.find_elements_by_css_selector("input[type='text'][name='TAN']")[0]
tan.click()
tan.send_keys("something")