Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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"

>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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading