This issue is inconsistent. When I freshly record those three lines again, the script is executing fine. But when I move those lines of code to a login function and when the function is called, the script fails while entering the password.
Today I noticed the same issue on another application (.Net application). Failed exactly for the same reason.
Is there a chance that Windows XP service pack 3 is causing this issue?