Wanted to perform hover on nav menu item which should show the sub menu.
chrome.scripting.executeScript(
{
target: {tabId: tabId},
func: hoverFunction,
args:[id]
},
(injectionResults) => {
// perform something post execution
});
function hoverFunction(id){
let element = document.getElementById(id);
element.addEventListener('mouseover', function() {
console.log('Event triggered');
});
var event = new MouseEvent('mouseover', {
'view': window,
'bubbles': true,
'cancelable': true
});
element.dispatchEvent(event);
}
Tried to simulate the mouse over event on a menu item, I see the event getting triggered as I see console log getting printed but the submenu doesn't popup on script execution..
Tried to simulate/dispatch the mouse over event on a menu item, I see the event getting triggered as I see console log getting printed but the submenu doesn't popup on script execution..
My expectation is I should be able to automate/perform hover on a element with script and get the expected events to happen..In this case , the submenu to popup or to show tooltip for the elements if any on mouseover..