PowerShell with Internet Exporer Login information not working

Hello everyone,
I am trying to login to a website and here are the two line that PS executes

$ie.Document.getElementById("js-username").value = "xxxx"
$ie.Document.getElementById("password_field").value = "xxxxxxxxx"

when these two line executes somehow my old password shows up in the field. I have checked it with inspect elements and I see my old password. When I copy paste the same password from the code it works.
What is happening? Anyone knows?

IE is probably auto-remembering your old password and filling it in, overwriting whatever you’ve programmatically inserted. You might try putting a Start-Sleep between the end of the page load and you inserting those values. That should give IE time to auto-fill, and then you can overwrite those values. Or, dis-remember the remembered values for that page.