I am working on an automatic login feature by filling in the username and password for a web application using javascript. The password field has the autocomplete feature activated. It's HTML is as below -
<input name="autofill_password" type="password" style="display:none">
<input name="user_password" type="text" onfocus="this.setAttribute('type', 'password')" id="user_password" maxlength="256" class="loginField" autocomplete="new-password">
I am unable to set the value using javascript or jquery for the "user_password" field. I have tried the following with no luck -
$('#user_password').val("g");
$('#user_password').attr('value', 'new value');
document.getElementById('user_password').value = 'Welcome!1';
document.getElementById('user_password').setAttribute('type', 'text');
What is preventing the setting of the value and what else can I try?