I'm trying to simulate a search in Linkedin.com in Javascript console (I need to do it in Javascript, for a chrome extension development... not in Phantom, Selenium or other browser-simulation environments).
If I do this:
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('focus', { bubbles: true }))
it seems it changes like the cursor was on it (because it triggers something in CSS behaviors and the field growths).
But I can't get to type something in the input field. My tries:
document.querySelector(".search-global-typeahead__input").dispatchEvent(new KeyboardEvent('keypress',{'key':'a'}));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new KeyboardEvent('keydown',{'key':'a'}));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('change'));
document.querySelector(".search-global-typeahead__input").dispatchEvent(new Event('click'));
...
I can use a simple "value":
document.querySelector(".search-global-typeahead__input").value = "Peter"
but then how can I trigger the search? I tried with keydowns and others ...
Any idea?