I've gone through all the links that direct me towards using .focus() and/or auto focus(I don't need auto-focus as my work doesn't involve handling the html). I have to focus on the gmail's input field and populate it with the user's email passed.
The following works fine if run separately, it populates the field but if I run it with focus() command it doesn't bring it to focus.
document.getElementById("identifierId").value = "abcdefgxyz@gmail.com";
The commands that I tried running in the console are:
document.querySelector("#identifier").focus()
document.querySelectorAll('input[type=email]')[0].focus(function() {document.getElementById("identifierId").value = "abcdefghijk@gmail.com";})
document.querySelectorAll('input[type=email]')[0].focus()
document.querySelectorAll('input')[0].focus()
document.getElementById("identifierId").value = "abcdefghijk@gmail.com";