Trying to login to a website using selenium python

Question:

I am trying to login to a website using selenium python, the browser is Internet Explorer and yes the website only works properly in internet explorer.

I have written the below code to enter the username:

uname = driver.find_element(By.ID, "UserName").send_keys("RParihar")

When I run the code it should enter "RParihar" in the username field but, it is entering "rParihar" instead.

enter image description here

I have tried using the following line of codes:

uname = driver.find_element(By.ID, "UserName").send_keys("RParihar")

And

uname = driver.find_element(By.ID, "UserName")
uname.send_keys("RParihar")

And also,

uname = driver.find_element("id", "UserName")
uname.send_keys("RParihar")

I have also tried using the XPATH locator strategy.

uname = driver.find_element(By.XPATH, "//*[@id="UserName"]")
uname.send_keys("RParihar")

Still it is entering "rParihar" instead of "RParihar"

Asked By: Dev

||

Answers:

driver.find_element(By.ID, "UserName").click()
uname = driver.find_element(By.ID, "UserName")
uname.send_keys("R")

maybe work this code but i am not sure

Answered By: eaglescofield

Try using JS to enter test and see if it works:

driver.execute_script("return document.getElementById('UserName').value='RParihar'")

Or try the below code if that works:

driver.find_element(By.ID, "UserName").clear()
driver.find_element(By.ID, "UserName").click()
driver.find_element(By.ID, "UserName").send_keys("RParihar")
Answered By: Shawn