我的 Applescript 在 Safari 中(偶尔)遇到此错误。
Result:
error "Safari got an error: Can’t get document \"DOC TITLE\"."
number -1728 from document "DOC TITLE"
我认为这是因为页面没有加载,但我有一个 Javascript 来检查“完成”,然后再继续,还有一个 try 语句可以在出错时再延迟一秒。
尽管如此,我仍然遇到这个问题。这似乎是相当随机的。
有什么建议么?
Applescript(整个 Tell 语句):
tell application "Safari"
set the URL of the front document to searchURL
delay 1
repeat
if (do JavaScript "document.readyState" in document 1) is "complete" then exit repeat
delay 1.5 -- wait a second before checking again
end repeat
try
set doc to document "DOC TITLE"
on error
delay 1
set doc to document "DOC TITLE"
end try
set theSource to source of doc
set t to theSource
end tell