For study purposes I'm trying to make an automated login on the web version of Instagram (https://www.instagram.com/accounts/login/).
I thought the task would be easily achieved by just filling out the username and password fields, and then submitting the form; however it's not working, the form is submited with
These are the elements involved:
<input class="_2hvTZ pexuQ zyHYP" aria-label="Phone number, username, or email" aria-required="true" autocapitalize="off" autocorrect="off" maxlength="75" name="username" type="text" value="">
<input class="_2hvTZ pexuQ zyHYP" aria-label="Password" aria-required="true" autocapitalize="off" autocorrect="off" name="password" type="password" value="">
<button class="sqdOP L3NKy y3zKF" disabled="" type="submit"><div class=" Igw0E IwRSH eGOV_ _4EzTm ">Log In</div></button>
So here is the code I'm using to fill the elements and submit the form:
document.getElementsByName('username')[0].value = 'myusername';
document.getElementsByName('password')[0].value = 'mypassword';
document.getElementsByTagName('button')[0].removeAttribute("disabled");
document.getElementsByTagName('button')[0].click();
document.getElementsByName('username')[0].value = 'myusername';
document.getElementsByName('password')[0].value = 'mypassword';
document.getElementsByTagName('button')[0].click();
<input class="_2hvTZ pexuQ zyHYP" aria-label="Phone number, username, or email" aria-required="true" autocapitalize="off" autocorrect="off" maxlength="75" name="username" type="text" value="">
<input class="_2hvTZ pexuQ zyHYP" aria-label="Password" aria-required="true" autocapitalize="off" autocorrect="off" name="password" type="password" value="">
<button class="sqdOP L3NKy y3zKF" disabled="" type="submit"><div class=" Igw0E IwRSH eGOV_ _4EzTm">Log In</div></button>
The first two lines would fill the fields and fourth line would submit the form; somehow this won't work. Actually even the lines that fill the fields don't seem to work properly, because when i submit the form, i can see no field was sent to the server.
It seems the problem is related to something about React, but why is my code not working? It should work as it's pure JavaScript; what am I missing here?
