Selenium Python Send_Key Error: List Object Has No Attribute

selenium python send_key error: list object has no attribute

You are getting a List of webElements with driver.find_elements_by_xpath(".//*[@id='UserName']") which of course not a single element and does not have send_keys() method. use find_element_by_xpath instead. Refer to this api doc.

userID = driver.find_element_by_xpath(".//*[@id='UserName']")

userID.send_keys('username')

Selenium AttributeError 'list' object has no attribute send_keys

  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
  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)

Attribute Error: 'list' object has no attribute 'send_Keys' - Selenium

driver.find_elements_by_name("form:email:input")

will return a list not a single web element. so search is a list in your case not a web element.

send_keys 

from selenium is meant for WebElement.

use find_element instead that will return a WebElement not list of web elements.

search = driver.find_element_by_name("form:email:input")

Error with selenium for send_keys : str' object has no attribute 'send_keys'

Clear the placeholder, then send keys :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
import time

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')

driver= webdriver.Chrome(options = options)

url= "https://healthunlocked.com/"

driver.get(url)

# closing cookies thing
driver.find_element_by_id('ccc-notify-accept').click()

loginpage= driver.find_element_by_id("sitebar-login-button").click()

time.sleep(3)

user_ele = driver.find_element_by_id('email')
user_ele.clear()
user_ele.send_keys('MyEmail@gmail.com')

pass_ele = driver.find_element_by_xpath('//*[@id="password"]')
pass_ele.clear()
pass_ele.send_keys('MyPassword')

# submitting
driver.find_element_by_xpath('/html/body/div[3]/div/div[1]/div/div/section/div[1]/form/button').click()
time.sleep(10)

driver.quit()

if you just want to login, you can use requests to send a post request

AttributeError when trying to use send_keys

send_keys() is an element method, not a webdriver method.

When you call find_element_by_id(), you have to save the returned element and then you can call send_keys() on that element.

username_element = driver.find_element_by_id('username')
username_element.send_keys('admin')


Related Topics



Leave a reply



Submit