[英]Applescript : wait that the page is load on chrome
tell application "Safari"
repeat until (do JavaScript "document.readyState" in tab 2 of window 1) is "complete"
end repeat
end tell
end if
我怎样才能在 Chrome 中使用它?
你应该能够做到
tell application "Google Chrome"
repeat until (execute tab 1 of window 1 javascript "document.readyState" is "complete")
end repeat
execute tab 1 of window 1 javascript "document.readyState"
end tell
但是您的页面可能会永远或长时间返回“交互式”。
只使用 AppleScript 应该是:
tell application "Google Chrome"
repeat until (loading of tab 1 of window 1 is false)
1 + 1 --just an arbitary line
end repeat
loading of tab 1 of window 1 --this just returns final status
end tell
但是,说实话,我觉得这很可疑。 我有一个页面,正文中的 html 非常简单( http://www.crgreen.com/boethos/boethos.html ),它适用于该页面,但对于大多数页面(我已经尝试过 yahoo、macupdate、bbc 新闻) 、jedit.org 等)我从来没有得到过“loading = true”。 它可能是越野车。
对于 Chromium 浏览器(Google Chrome、Brave 浏览器、Microsoft Edge、Opera、Vivaldi 等),您不需要 JavaScript 解决方法,因为它们已适当支持检查选项卡是否仍在加载。
在 AppleScript 中:
tell application "Google Chrome" to return loading of tab 2 of window 1
在 JavaScript for Automation (JXA) 中:
Application('Google Chrome').windows[1].tabs[2].loading()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.