I have been trying to set up a search in Safari using script commands I found in UI Browser.
There are three lines in the code below.
- To set a value in the search block
2.To return the value just set - Select the text that was supposed to have been set in line 1.
This is the code.
activate application "Safari"
tell application "System Events"
tell process "Safari"
set value of UI element 1 of group 4 of toolbar 1 of window 1 to "yahoo"
get value of UI element 1 of group 4 of toolbar 1 of window 1
select UI element 1 of group 4 of toolbar 1 of window 1
end tell
end tel
l
and this is the result
tell application “Safari”
activate
end tell
tell application “System Events”
set value of UI element 1 of group 4 of toolbar 1 of window 1 of process “Safari” to “yahoo”
get value of UI element 1 of group 4 of toolbar 1 of window 1 of process “Safari”
→ missing value
select UI element 1 of group 4 of toolbar 1 of window 1 of process “Safari”
→ UI element 1 of group 4 of toolbar 1 of window “Untitled spreadsheet - Google Sheets” of application process “Safari”
end tell
Result:
UI element 1 of group 4 of toolbar 1 of window “Untitled spreadsheet - Google Sheets” of application process “Safari” of application “System Events”
It processes all the commands but returns “missing value” after line 1 & 2 and then returns the value in the box without making any changes from line 3. The last line proves I think that I am in the correct box.
Any suggestions greatly appreciated
Thanks
Peter