我尝试了这么多剪辑但是无法让我的脚本等待safari(9.0.1)来满载我想要的网页。
任何适用于OSX 10.11 / Safari 9.0.1的想法?
此外,目前我还有一个非常简单的时间对话“是safari满载?”
但是,我的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
答案 0 :(得分:2)
检查Safari是否已完成加载整页的简单方法是检查页面的源代码是否包含结束应答#34;"。
这个脚本正在这样做:
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指令以获取页面加载状态。它也是这样。