Applescript JavaScript "End of Line but found identifier" 控制时出错 Google Chrome

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

以下是我的 AppleScript 脚本的一部分,应该单击 Google Chrome 当前选项卡中名称为 'connect'.

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

运行时,returns出现以下语法错误:

Expected end of line but found identifier.

我如何让它工作?

没关系。我想通了。

代码如下:

tell application "Google Chrome"
    execute front window's active tab javascript "document.getElementsByName('connect')[0].click()"
end tell