Macos AppleScript在safari错误中单击按钮
我试图在safari中使用applescript在网页上单击一个简单的按钮。我有以下代码:Macos AppleScript在safari错误中单击按钮,macos,button,safari,applescript,automator,Macos,Button,Safari,Applescript,Automator,我试图在safari中使用applescript在网页上单击一个简单的按钮。我有以下代码: tell application "Safari" activate repeat 5 times do JavaScript "document.all(\"Roll Again\").click()" in document 1 delay 2 end repeat end tell 然而,当我运行这段代码时,我得到一个错误:“缺少值”。事件日
tell application "Safari"
activate
repeat 5 times
do JavaScript "document.all(\"Roll Again\").click()" in document 1
delay 2
end repeat
end tell
然而,当我运行这段代码时,我得到一个错误:“缺少值”。事件日志显示以下结果:
tell application "Safari"
activate
do JavaScript "document.all(\"Roll Again\").click()" in document 1
--> missing value
do JavaScript "document.all(\"Roll Again\").click()" in document 1
--> missing value
do JavaScript "document.all(\"Roll Again\").click()" in document 1
--> missing value
do JavaScript "document.all(\"Roll Again\").click()" in document 1
--> missing value
do JavaScript "document.all(\"Roll Again\").click()" in document 1
--> missing value
end tell
有人能告诉我为什么没有按下按钮以及缺少的值是什么意思吗?有没有其他更简单的方法来实现按钮按下?我可以使用automator按下按钮,但是我想使用AppleScript
p.S.文档是safari中的当前窗口特定于IE,在safari中不起作用。尝试使用getElementById或querySelectorAll:
tell application "Safari"
activate
tell document 1
do JavaScript "document.getElementById(\"nav-badges\").click()"
delay 5
do JavaScript "document.querySelectorAll(\"#hmenus a\")[0].click()"
end tell
end tell
请包括网址。可能有用