Trying to type into a field with AppleScript
I'm trying to write a script that will remove a set of cookies from Safari. I can get the Preferences window open and setting the focus in the search field. At that point, the script fails (see "<<<" below). Any thoughts as to why the strings aren't being placed into the search field?
TIA,
David
===================
set deCookie to {"newsweek.com", "newyorker.com", "cnn.com"}
tell application "System Events"
tell application process "Safari"
set frontmost to true
keystroke "," using command down
delay 1
tell window 1
click button "Privacy" of toolbar 1 of it
try
click button "Manage Website Data…" of group 1 of group 1
-- give cookies time to load in their scrollable window
delay 3
repeat with d in deCookie
click text field "Search"
try
keystroke d -- <<< this is where this script is failing <<<
delay 1
select row 1 of table 1 of scroll area 1 of sheet 1
click button "Remove" of sheet 1
end try
end repeat
click button "Done" of sheet 1
on error errmsg number errnbr
keystroke "w" using command down
display alert "No cookies to remove" giving up after 5
return
end try
end tell
keystroke "w" using command down
display alert "All cookies removed" giving up after 5
end tell
end tell
return
MacBook Pro 13″, macOS 11.1