login to page using selenium

Viewed 96

Attached below is the login page screenshot. I am unable to figure out how to find class name of username or what can be the id for putting username. Basically i am trying to login here. enter image description here

I have tried

driver.find_elements_by_xpath("//*[contains(text(), 'Username')]").sendKeys("thakneh")

but the error i am getting is: 'list' object has no attribute 'sendKeys'. Also, driver.find_elements_by_xpath("//*[contains(text(), 'Username')]") part returns empty list.

1 Answers
list' object has no attribute 'sendKeys

this is because, you are using find_elements which will return a list in Selenium-Python bindings.

you can not perform send_keys to a list in Selenium - Python. It has to be a single web element.

try find_element instead. (this will return a web element not list of web elements)

driver.find_element_by_xpath("//*[contains(text(), 'Username')]").sendKeys("thakneh")

Update 1 :

driver.get("Your URL")
driver.maximize_window()
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Username']/../following-sibling::input"))).send_keys('username')
wait.until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Password']/../following-sibling::input"))).send_keys('password')
wait.until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Sign In']/.."))).click()

Imports :

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