AppleScript Code not working in Monterey OS with Safari version 15.1

Hi,

The below applescript code is working perfectly in BigSur OS with Safari 14.1 version.

But it is not working in “Monterey” OS with Safari 15.3 version. Please check and advise to resolve this issue.



tell application "System Events" to tell application process "Safari"
		repeat until (UI element "Reload this page" of group 2 of toolbar 1 of window 1 exists)
			delay 0.1
		end repeat
		click menu item "Show Web Inspector" of menu 1 of menu bar item "Develop" of menu bar 1
		delay 1
		set theSelection to value of attribute "AXFocusedUIElement"
		tell theSelection to perform action "AXShowMenu"
		delay 1
		keystroke "Capture Screenshot" & return
		
		repeat until sheet 1 of window 1 exists
			delay 0.01
		end repeat
		
		set value of text field 1 of sheet 1 of window 1 to theName
		
		
		-- Set (go to) destination folder
		keystroke "g" using {command down, shift down}
		delay 0.1
		set value of combo box 1 of sheet 1 of sheet 1 of window 1 to destinationFolderPosixPath
		delay 0.1
		click button "Go" of sheet 1 of sheet 1 of window 1 --to accept folder
		
		click button "Save" of sheet 1 of window 1
	end tell

Model: iMac (Retina 5K, 27-inch, 2017)
AppleScript: 2.11
Browser: Safari 15.3
Operating System: macOS 12