I want to programmatically set focus on the web.whatsapp.com search bar:
I inspect this element in Chrome 's source code explorer, and I see this:
I right-click the element, then click "Copy->selector".
It provides: "#side > div.uwk68 > div > div"
So I tried this:
var inputElements = document.getElementsByClassName('#side > div.uwk68 > div > div');
It returns 0 elements.
How could I select this search bar?
Thank you very much!
I think you can use document.querySelector like
var element = document.querySelector("div._13NKt.copyable-text.selectable-text");
This is listed along with the other things you can use in this reference for the HTML DOM