Unable to click the Chrome popup dialog using KM

I have used to click buttons on the webpage using javascript through KM without any problem. However, I couldn't click the popup window in Chrome. Take an example...

In the print dialog, I would like to click the "Cancel" button.

In the console, I used the following script to click the button successfully
document.querySelector("body > print-preview-app").shadowRoot.querySelector("#sidebar").shadowRoot.querySelector("print-preview-button-strip").shadowRoot.querySelector("div > cr-button.cancel-button").click()

However, the same script didn't work by using KM

Certainly, I could use multiple keystokes ("tab") to perform the same task alternatively. However, I would like to understand why the JS failed in the popup dialog.

Thank you very much!

You might try disabling Modern Syntax using the disclosure triangle to the left of the JavaScript box. I'm not positive that'll work, but it's something to try.


1 Like

Thank you for your prompt reply! However, I've already tried to disable Modern syntax (as you mentioned it yesterday) but the script didn't work too.

Ah, sorry—didn't realize this was the same user :).