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
- You have to wait until the page is loaded and the element is presented there
- You should use
find_element_by_xpath
, notfind_elements_by_xpath
- 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
Checking If a Pair of Value Is Inside a 2D Array Python
Python:Compare Two CSV Files and Print Out Differences
How to Append Dataframes Inside a for Loop in Python
How to Make the Program to Rerun Itself in Python
Django Rest Framework Csrf Failed: Csrf Cookie Not Set
What Is the Easiest Way to Convert Ndarray into Cv::Mat
How to Get the Amount of Consecutive Sub Strings of an Object in a List
How to Simply Add a Column Level to a Pandas Dataframe
Efficient Date Range Overlap Calculation
How to Remove Comma and Brackets
How to Split Vector into Columns - Using Pyspark
Comparing Two Dataframes and Getting the Differences
Convert Pandas Dataframe to Numpy Array
How to Append Data Using Openpyxl Python to Excel File from a Specified Row
How to Download Outlook Attachment from Python Script
How to Print Superscript in Python
How to Change the Foreground or Background Colour of a Tkinter Button on MAC Os X