I'm trying to fill out a Username and Password field on a website. The id changes every time, so I cant find the elements by using the id. So I tried by using XPath and class name, but none of them worked. This is my code:

user_name_elem = driver.find_element_by_xpath("//input[contains(@class, 'mu-input__field mu-input__field--error')]")
user_name_elem.send_keys('[email protected]')

for the password, I tried the same and it didn't work, for both I just I get an "unable to locate element".

This is the HTML of the Website:

The field for E-mail Adress:

<input type="email" id="lfte2w" name="emailAddress" placeholder="E-Mail-Adresse" autocomplete="on" class="mu-input__field mu-input__field--error"> 

For the password:

<input type="password" id="c2juvc" name="password" placeholder=" Passwort" autocomplete="on" class="mu-input__field">

And this is the link to the Login page: https://www.mueller.de/login/

  • you have link to the website?
    – PDHide
    Commented Jun 8, 2021 at 16:36

3 Answers 3


Use correct XPath to find the locator, once the locator is correct you can very well use the .sendkeys() method to type into the field. use chrome browser inspect element and try not to overcomplicate the XPath. For the username and password fields usually, a simple locator will work like id, name, type anything. You are using the @contains function which is not required.


What about using the 'name' of the element?

Something like this (in Python) - find_element(By.NAME, "emailAddress") - similar thing for "password".

  • Thanks! It worked but now I got i new Problem, see above in the comment section of Mats answer.
    – LordB
    Commented Jun 9, 2021 at 12:13

Use name tag for locating elements.

// For Email Address
username = driver.find_element_by_name('emailAddress')
// For Password
password = driver.find_element_by_name('password')

For better understanding, you can check Locating Elements

  • Thanks! It finds the element now. I imported the common.keys import Keys, but if I try to use sendkeys() it doesn't fill out the field. And pycharm doesn't suggest it to me either if I start typing. Btw: I would really like to upvote your comments but I can't do that yet with only 1 reputation.
    – LordB
    Commented Jun 9, 2021 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.