Pressing a button in Google Chrome or Firefox web page using applescript


It's not actually a KM question but i can't get it and hope that some one will help me with this.

I am willing to use applescript to with KM macro to press a button (button id="signInSubmit") on a webpage (mostly in Firefox), the applescript code is:


tell application "Firefox"

do JavaScript "document.getElementById('" & signInSubmit & "').click();" in document 1

end tell

end clickID

Tell me please what is wrong with the code, because it's not working.

Thanks a lot in advance.

Firefox doesn’t support AppleScript, so that would explain why this script isn’t working.

Oh, okay :frowning:
Thank you for the fast answer.

But injecting a bookmarklet via the URL bar might well work. So long as you know the button’s id.

Could you provide an example of it?

Sorry I don’t have time to do a worked example but your fragment of javascript is about right.

You need to URL encode it and prefix it with javascript: and inject it into the URL bar.

Cmd+L gets you the URL bar. Then paste by typing and then send the Enter key.

###Macro: Firefox Execute Bookmarklet Javascript