How to Implement arrow key (down or up) in webpagetest script to select dropdown item

I’m new to WebPagetest (https://www.webpagetest.org/) and I am not sure how to implement arrow key (down/up) to select the first item which is appearing in dropdown window after I performing a search. example code is given below

execAndWait el = document.querySelector("<xyz input>"); proto = Object.getPrototypeOf(el); set = Object.getOwnPropertyDescriptor(proto, "value").set; set.call(el, "<searchItem>"); el.dispatchEvent(new Event("input", { bubbles: true }))
sendKeyEventAndWait('keydown', 40);
sendKeyEventAndWait('keyup', 40);

Trying to select the dropdown item and then click on it

Leave a Comment