i’m making a an applescript with ui scripting and i need to be able to open a number of tabs in safari and set each one to a certain URL.
the best way i know of doing this is along the lines of…
tell application “System Events”
tell process “Safari”
repeat y times
click menu item “New Tab” of menu “File” of menu bar 1
set the URL of document 1 to item x of urlList
set x to x + 1
end repeat
end tell
end tell
It works well except that it only types the URL into the URL bar and doesn’t press return before going on to the next tab, how would i make it press return?
Also as a side note, is it possible to ask safari (through a ui script of course) which tab ( or “radio button”) is in front?
As for reporting which tab is in front, I took a look at a couple tabs with PreFab’s UI Browser and there does seem to be an attribute “value” (# 10 in the Attributes list) associated with each radio button which is 0 for all except the active (in front) tab. On the active tab, it’s 1.
if the URL bar is empty or contains invalid text then an alert (in the form of a sheet) pops up and the next tab ends up being opened in a new window (press cmd+ N then return then cmd+ t in safari to see what i mean)
Is there some way i can ask safari whether such a sheet has appeared?
Or is there something else i could do?
Thanks
(for future reference should i have started a new post for this?)