Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applescript JavaScript "End of Line but found identifier" Error when controlling Google Chrome

The following is a part of my AppleScript script that should click an element in the current tab of Google Chrome with name 'connect'.

tell app "Google Chrome"
do JavaScript "document.getElementsByName('connect').click();" in current tab of first window
end

When is runs, it returns the following syntax error:

Expected end of line but found identifier.

How would I get this to work?

like image 274
woff Avatar asked Dec 01 '25 16:12

woff


1 Answers

Never mind. I figured it out.

Here's the code:

tell application "Google Chrome"
    execute front window's active tab javascript "document.getElementsByName('connect')[0].click()"
end tell
like image 83
woff Avatar answered Dec 03 '25 07:12

woff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!