Applescript JavaScript“;行尾但找到标识符“;控制Google Chrome时出错

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

本文关键字:Google 控制 Chrome 标识符 出错 JavaScript Applescript      更新时间:2023-09-26

以下是我的AppleScript脚本的一部分,该脚本应该单击Google Chrome当前选项卡中名为"connect"的元素。

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

当is运行时,它返回以下语法错误:

应为行尾,但找到标识符。

我该如何让它发挥作用?

没关系。我想明白了。

这是代码:

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