AppleScript:Safari 页面完全加载/全屏对话框 windows

AppleScript : Safari page fully loaded / Dialog in full screen windows

我尝试了这么多片段,但无法让我的脚本等待 safari (9.0.1) 完全加载我想要的网页。

任何与 OSX 10.11 / Safari 9.0.1 一起工作的想法?

此外,目前我有一个非常简单的时间对话"is safari fully loaded?"

但是我的 Safari 是全屏打开的,所以对话框会在主桌面屏幕上弹出。

我可以不将对话框聚焦到 safari 所在的位置吗?

set infotosearch to the clipboard

if infotosearch is equal to missing value then
    --do nothing
else
    tell application "Safari"

        tell window 1 of application "Safari" to set current tab to tab 1
        -- Last Name
        do JavaScript "document.getElementsByName('11111')[0].value=" & quoted form of infotosearch & "" in document 1
        -- search
        delay 0.1
        do JavaScript "document.getElementsByName('111112')[0].click();" in document 1
    end tell
end if

-- FOCUS ON SAFARI 

tell application "System Events"
    tell process "Safari"
        set frontmost to true
        delay 1
    end tell

end tell
-- END FOCUS 

-- Dialog as cannot wait for safari page fully loaded

display dialog "Is MZ Fully loaded?" buttons {"Yes", "NO"} default button 2
if the button returned of the result is "" then
    -- nothing
else
    -- nothing
end if

检查 Safari 是否已完成加载整个页面的一种简单方法是检查页面的源代码是否包含结尾应答器“”。

这个脚本就是这样做的:

set myUrl to "http://www.google.com"
tell application "Safari"
make new document with properties {URL:myUrl}
delay 1
tell document 1
    repeat until ("</html>" is in its source)
        delay 0.5
    end repeat
end tell
end tell

希望对您有所帮助。

我还记得看到过 java 获取页面加载状态的指令。它也是一样的。