Trying to create a macro to activate 'Google Voice Search' in Chrome

I'm trying to create a macro that will activate Chrome, open a new tab, then click on the 'Search by voice' button in the search field.

I've tried to create a macro that will look for the 'Search by voice' icon/image on the screen and click it, but haven't managed to get it to work.

I've also tried another version of the macro that looks for the button called 'Search by voice' and then clicks it, but can't get that one to work either.

Although I've used Keyboard Maestro for years I never created a macro that would try to click on an image or button, so it's quite possible that this is user error.

Any ideas on what I need to do to get this to work?

This seems to work for me. I use KM's Focus of Google Chrome field to focus on the button, then hit return.

The trick was figuring out that Focus Field entry. Turns out the Google Chrome Developer tools will give it right to you.

Turn on the developer tools in chrome, click the little box with an arrow into a box icon in the developer tools tab bar, select the element you're interested in, click the ... next to the entry it highlights, select Copy > JS Path. I think you can use the XPath too?

The path this turned up for me is:
document.querySelector("body > ntp-app").shadowRoot.querySelector("#realbox").shadowRoot.querySelector("#voiceSearchButton")


That's it, thanks!

I was using the web inspector to locate the button, but didn't know about 'Focus Google Chrome Field.