'Auto focusing on the gmail input field and then auto-filling it

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.

enter image description here

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 = "[email protected]";

enter image description here

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 = "[email protected]";})
document.querySelectorAll('input[type=email]')[0].focus()
document.querySelectorAll('input')[0].focus()
document.getElementById("identifierId").value = "[email protected]";


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source