Hi Tanya,
Unfortunately it seems that doesn't work in this case. If I have two browser windows, neither is maximised, and one partially overlapping the other, then both Visible and VisibleOnScreen are TRUE for both pages.
If I line them both up so they are completely aligned and the same size, or of course if one is smaller than the other which is completely overlapping it - then VisibleOnScreen is FALSE for the hidden one.
But by default, the new window is opened the same size, partially offset from the original window - and as such, both windows have both visible settings TRUE
NOW, that said - the above is in IE. If I repeat the test in Chrome then a new TAB is opened, rather than a window - and in this case, both Visible settings are TRUE/FALSE as you would expect. Also in this case, there is only ONE Sys.Browser("chrome").BrowserWindow object - whereas of course when IE opens new windows, there is a BrowserWindow object "per page".
If it helps, I can tell you that as part of my test I have a test start event that closes ALL browser windows first - so only the browser windows related to the test are open.
As an aside, I've yet to see what happens in FF or Safari. I'm guessing FF will be in line with either IE or Chrome, and that's fine. Safari will probably go off and do something completely different ;-)
One idea I had was Sys.Browser().FindAllChildren("ObjectType","BrowserWindow")
then take the window with the highest ObjectIdentifier value, and link to the visible (and probably only) page belonging to this value - but its the "belonging" relationship I cannot work out!
So in summary - multiple tabs is easily dealt with, as per your suggestion. multiple browser windows - not so easy - vislble and visibleonscreen don't help, and focused doesn't seem to work as one might expect.