Safari Tabbing

So I thought I did my HW, but I have to ask here. I looked around and found various sites saying that Safari’s Tabs (instead of having multiple windows, using tabs within one window) aren’t scriptable. But when I use the UI browser, it gives a command that looks like it should work. Though, in the same token, I’m still figuring out how to use the output of UI Browser and get that data to work in Applescript.

also, if someone could point me in the right direction on how to “translate” the UI browser into AS, that’d be wonderful.

here’s what the UI browser gives me:


click button "Amazon"  of group 2 of window "Tower.com Books: Online shopping for Bestseller Books, Textbooks, Calendars and more" 

Thanks!

The problem with GUI scripting is that things aren’t static… for example the UI Browser told you group 2 while mine says group 3 so I have a toolbar or some such UI element turned on that you do not. Also your tabs might not always be names the same just like the window name might not be.

So that said this example works for me.

activate application "Safari"
tell application "System Events"
	tell process "Safari"
		click button "Apple - Start" of group 3 of window "MacScripter BBS | Applescript Forums / AppleScript | OS X"
	end tell
end tell

You can also refer to items by number instead of names so I could have written that like this

activate application "Safari"
tell application "System Events"
	tell process "Safari"
		click button 1 of group 3 of window 1
	end tell
end tell

Hope that helps!