简体   繁体   English

Selenium AttributeError 'list' object 没有属性 send_keys

[英]Selenium AttributeError 'list' object has no attribute send_keys

I want to use Selenium for automate a login in the website https://clientes.ecuabots.com/user/login我想使用 Selenium 自动登录网站https://clientes.ecuabots.com/user/login

This is my code:这是我的代码:

class EcuabotsTest(unittest.TestCase):

def setUp(self):
    self.driver =  webdriver.Chrome(executable_path='/mnt/c/Users/Barbara/Documents/Formación Continua/Selenium/chromedriver.exe')
    driver = self.driver
    driver.get('https://clientes.ecuabots.com/user/login')
    driver.maximize_window()
    #driver.implicitly_wait(15)

def test_search_email_input(self):
    email_field = self.driver.find_elements_by_xpath('//*[@id="input-15"]')
    email_field.clear()
    
    email_field.send_keys('email@email.com)



if __name__ == "__main__":
    unittest.main(verbosity=2)

but when i try this way i have the error: AttributeError 'list' object has no attribute send_keys但是当我尝试这种方式时出现错误: AttributeError 'list' object has no attribute send_keys

  • I tried to use email_field = self.driver.find_element_by_xpath('// [@id="input-15"]') (singular) but i get this error: selenium.common.exceptions.NoSuchElementException: Message: No such element: {"method":"xpath","selector":"// [@id="input-15"]"我尝试使用 email_field = self.driver.find_element_by_xpath('// [@id="input-15"]') (单数)但我收到此错误:selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素: {"method":"xpath","selector":"// [@id="input-15"]"

  • I tried the find email input with id, CSS selector and full XPath but it isn't work我尝试使用 id、CSS 选择器和完整的 XPath 查找 email 输入,但它不起作用

  • I tried to use email_field[0].send_keys('email@email.com) but i get the first error again我尝试使用 email_field[0].send_keys('email@email.com) 但我再次收到第一个错误

Thank you very much beforehand for your help!非常感谢您的帮助!

  1. You have to wait until the page is loaded and the element is presented there您必须等到页面加载并且元素出现在那里
  2. You should use find_element_by_xpath , not find_elements_by_xpath您应该使用find_element_by_xpath ,而不是find_elements_by_xpath
  3. Your locator is wrong您的定位器错误

Try this:尝试这个:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

email_input_css = 'input[placeholder="Email Address"]'

wait = WebDriverWait(browser, 20)

email = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, email_input_css)))
email_field.clear()
email_field.send_keys('email@email.com)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:“ Selenium”对象在Selenium和Python中没有属性“ send_keys” - AttributeError: 'selenium' object has no attribute 'send_keys' with Selenium and Python AttributeError: 'dict' object 没有属性 'send_keys' Selenium Webdriver - AttributeError: 'dict' object has no attribute 'send_keys' Selenium Webdriver Selenium Python AttributeError: 'NoneType' 对象没有属性 'send_keys' - Selenium Python AttributeError: 'NoneType' object has no attribute 'send_keys' Python Selenium - AttributeError: 'WebElement' object 没有属性 'send_Keys' - Python Selenium - AttributeError: 'WebElement' object has no attribute 'send_Keys' AttributeError: 'WebDriver' object 在 selenium python 中没有属性 'send_keys' - AttributeError: 'WebDriver' object has no attribute 'send_keys' in selenium python AttributeError: 'WebElement' object 没有属性 'send_Keys' python selenium - AttributeError: 'WebElement' object has no attribute 'send_Keys' python selenium 错误 AttributeError: 'list' object 没有属性 'send_keys' - erorr AttributeError: 'list' object has no attribute 'send_keys' 属性错误:'list' object 没有属性'send_Keys' - Selenium - Attribute Error: 'list' object has no attribute 'send_Keys' - Selenium AttributeError: 'list' object has no attribute 'send_keys' error using Excel sheet to get the data through Selenium and Python - AttributeError: 'list' object has no attribute 'send_keys' error using Excel sheet to get the data through Selenium and Python AttributeError: 'str' 对象在 Python 中使用 Selenium 没有属性 'send_keys' 错误 - AttributeError: 'str' object has no attribute 'send_keys' error using Selenium in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM