2
votes

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?

1
Have you seen this answer? stackoverflow.com/questions/6561452/… There may be some similarity in the target syntax?Radio
Yeah, tried that one. I wouldn't have posted the question if I had tried other answers and they worked.woff
I wouldn't have asked if I thought the answer worked. I was ruling out two possible answers that I had bookmarked in the past on the topic. It just so happens the second one is the one that worked for you.So glad you got it working. These things can be so frustrating. Yay! So this question should be marked as duplicate. Have a nice evening! Here's the duplicate: stackoverflow.com/questions/5135609/…Radio
Well.. Alright. Thanks.. I guess.woff

1 Answers

3
votes

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