Trying to login to a website using selenium python

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


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

And also,

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

I have also tried using the XPATH locator strategy.

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

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

>Solution :

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

Leave a Reply