Clear Element Text doesn't seem to work

I’m new at Robot Framework and trying a simple authentication test scenario.
I start with the url of my email provider, fill in a wrong email adress and wrong password using:
Click Element xpath=//[@id=“ff-email”]
Input Text xpath=//
[@id=“ff-email”] wrong email adress
Click Element xpath=//[@id=“ff-password”]
Input Password xpath=//
[@id=“ff-password”] wrong password
After clicking on the login button I get the expected failure message.

So this works, at least in Chrome and Edge.

Now I want to replace the wrong email adress with the right one, using:
Click Element xpath=//[@id=“ff-email”]
Clear Element Text xpath=//
[@id=“ff-email”]
Input Text xpath=//*[@id=“ff-email”] right email adress

Result is over and over again that the test run itself passes, yet the wrong email adress is NOT cleared on the screen at hand, and the right email adress is pasted behind it (‘wrong email adressright email adress’).

Is this a bug, or do I do something wrong?

Hi Patrick,

Maybe try like this:

 Input Text    xpath=//*[@id=“ff-email”]     right email adress    clear=True

clear=True should be the default but maybe it’s not default in your test case for some reason?

Dave.

Hi Dave,

Tried that (Input Text xpath=//*[@id=“ff-email”] right.mailadress@provider.nl clear=True)
but the result is the same. Robot framework passes the test, but
With or without the ‘clear element text’ step before , the old input is not erased, the new value is pasted behind the old.
Any other suggestions? I can’t imagine being the only one testing authentications like this :face_with_peeking_eye:

Thanks, Patrick

That would have been my next suggestion, also a sleep of ~500ms between the clear element text and Input Text

Failing that it seems there might be some javascript on the page that’s interfering (form validation?)

I have seen instances where you couldn’t interact with the form fields directly, because of the styled elements that javascript framework generates on the page, the javascript would interfere and try to control the value of the <input> field.
If you have something like this you would need to click the <div> field, then use Press Keys to clear the field (CTRL+A DELETE) and then again to enter the new value, then the javascript will update the <input> value.

Dave.

Thanx Dave,
The Press Key suggestion solved this, so it seems to have been a Java script interference indeed!
Regards, Patrick

1 Like