[英]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!非常感谢您的帮助!
find_element_by_xpath
, not find_elements_by_xpath
您应该使用find_element_by_xpath
,而不是find_elements_by_xpath
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.