python selenium报错AttributeError: ‘list‘ object has no attribute ‘send_keys‘

代码如下:

driver.get("https://www.baidu.com/")
driver.find_elements_by_css_selector(".s_ipt").send_keys('1231')

报错如下:

Traceback (most recent call last):
  File "E:/ggggithub/automation_test/WebDriver_API/4.1元素定位_by_css.py", line 17, in <module>
    driver.find_elements_by_css_selector(".s_ipt").send_keys('1231')
AttributeError: 'list' object has no attribute 'send_keys'

解决方案如下:
把driver.find_elements_by_css_selector改为driver.find_element_by_css_selector即可,这是两种不同的用法

你可能感兴趣的:(python,selenium)