0

Good day community,

I would like your help to figure out what I'm doing wrong with my code.

I'm trying to enter my login information into my job site, but I got the error:

Exception has occurred: AttributeError 'list' object has no attribute 'send_keys'

I already check the documentation of Selenium package but I don't understand the possible solution.

here my current code

# Import python packages
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

# lauching browser with URL
browser = webdriver.Firefox()
browser.get('https://sso.central.conduent.com')

# Enter username
UserElem = browser.find_element_by_name('Ecom_User_ID')
UserElem.clear()
#here is where i got the error 
UserElem.send_keys('User#')


# Enter password
passwordElem = browser.find_element_by_name('Ecom_Password')
passwordElem.send_keys('Password#')

# click en boton
butonElem = browser.find_element_by_name('loginButton2')
butonElem.click()

2 Answers2

0

Try to change this row:

UserElem = browser.find_element_by_name('Ecom_User_ID')

to

UserElem = browser.find_element_by_css_selector('#Ecom_User_ID')

dimay
  • 2,768
  • 1
  • 13
  • 22
  • I changed that line of code but unfortunately did not work. I got this error, Exception has occurred: NoSuchElementException Message: Unable to locate element: #Ecom_User_ID – Kimochi Neina Aug 11 '20 at 07:28
  • You need some time wait until page loaded. https://stackoverflow.com/questions/26566799/wait-until-page-is-loaded-with-selenium-webdriver-for-python – dimay Aug 11 '20 at 07:57
  • Bad idea, but can help use `time.sleep(40)`. Put it in front of 'UserElem'. Don't forget `import time` – dimay Aug 11 '20 at 08:02
  • Wow!, Thank you @dimay, it works, i just include time.sleep before UserElem and wait for the page to load and enter user and password. – Kimochi Neina Aug 11 '20 at 17:51
0

You could try and locate them by using xpath, I did this myself a while ago with success. If you prefer you can use a browser extension to locate the xpath for you like XPath Helper for chrome.

chrome.find_element_by_xpath("//input[@id='userNameInput']").send_keys("username")
chrome.find_element_by_xpath("//input[@id='passwordInput']").send_keys("password")

Anyway, it ain't much but I hope it will be useful for you.

Mrvaandpyt
  • 47
  • 7
  • thank you for help me, i changed my code for user_input = driver.find_element_by_xpath( '//*[@id="Ecom_User_ID"]').send_keys(WINID) user_input.send_keys(WINID) as well for password, but I got the error Exception has occurred: NoSuchElementException Message: Unable to locate element: //*[@id="Ecom_User_ID"] – Kimochi Neina Aug 11 '20 at 07:31
  • Are you sure that's the right xpath your using? Alternatively try using the full xpath instead of going by id just to check if that works? Oh and plz upvote if I helped you :) – Mrvaandpyt Aug 11 '20 at 18:06
  • I double check and yes, it is the xpath, i was able to get the fully xpath also it works for me using time.sleep(40) – Kimochi Neina Aug 11 '20 at 18:15
  • Great, and good thinking about adding time. sleep to make sure that the page load. Although 40 seconds seems like long sleep time, usually I can get by with 1-2 seconds, and once in a full moon, I use 5 seconds. – Mrvaandpyt Aug 11 '20 at 18:41
  • i did not know that part well of the code well. time.sleep, now I understand your point, I'm changing the code to 5 second and works well. Thank you for your help – Kimochi Neina Aug 12 '20 at 04:55