I think WkWebView’s loading is completed….
-- Created 2015-09-16 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "WebKit"
property theWebView : missing value
set aRes to getPage(aURL)
theWebView
--> (WKWebView) <WKWebView: 0x6000003b9980>
on getPage(aURL)
set thisURL to current application's |NSURL|'s URLWithString:aURL
set theRequest to current application's NSURLRequest's requestWithURL:thisURL
set (my theWebView) to current application's WKWebView's new()
(my theWebView)'s loadRequest:theRequest
set waitLoop to 1000 * 60 --60 seconds
set hitF to false
repeat waitLoop times
set aLoadF to ((my theWebView)'s estimatedProgress()) as number
if aLoadF = 1.0 then
set hitF to true
exit repeat
end if
current application's NSThread's sleepForTimeInterval:("0.001" as real) --delay 0.001
end repeat
return hitF
end getPage