Here is my GUI Scripting code in case I prove to be enable to discover why the vanilla script refuses now to apply.
--{code}
(*
Save frontmost Safari document as WebArchive
Yvan KOENIG (VALLAURIS, France)
2014/01/15
*)
on run
local smallSheetAvailable, sourceName
tell application "Safari"
activate
end tell
(*
I use always this syntax to get rid of cases where the process 's name is not the application's one *)
tell application "System Events" to tell (first process whose frontmost is true)
(*
Some times I get a small sheet asking to make choice and offering the button "Cancel" and the default "Continue" *)
tell window 1
set smallSheetAvailable to false
repeat 20 times
delay 0.1
if exists sheet 1 then
set smallSheetAvailable to true
exit repeat
end if
end repeat
if smallSheetAvailable then
tell sheet 1
# class of UI elements
(*
Trigger Continue *)
keystroke return
end tell # sheet 1
end if
(*
Trigger the menu item Save As… *)
keystroke "s" using {command down}
(*
Wait for the availability of the save as sheet *)
repeat 5 times
delay 0.1
if exists sheet 1 then exit repeat
end repeat
(*
Sheet available, force target folder to Desktop *)
keystroke "d" using {command down}
(*
Define the file format thru the Format: menu *)
tell sheet 1 to tell group 1 to tell pop up button 1
click it
click menu item 2 of menu 1
end tell
(*
Really Saves *)
keystroke return
end tell # window 1
end tell # System Events …
end run
--{code}
I'm not fully satisfied because I don't understand what is deciding that a small sheet must appear just after opening the document.
I got it with make document as well as with open location.
The file is created on the Desktop so it's easy to move it elsewhere if needed.