reydimaano
12 years agoContributor
How to select each tab without knowing the url or tab title?
I have an IE browser opened which have 5 tabs. The current selected tab is the last one (tab 5). I want to jump to tab 2 without knowing the url.
- 12 years agoI would never want to suggest Tanya wasn't right - she's way smarter with TC than me - but I think a slight tweak to her code is required... I think her code in its current state is trying to click an entire array of tabs in a single click - while what you are looking to do is click the "nth" tab. With that in mind, blatantly stealing Tanya's code(!), and remembering arrays start at the 0th element:
function
ClickTabByNo(TabIndex) // Specify Tab Index as 1-5 "human form"
{
var
tabPanel = Sys.Browser(
"iexplore"
).BrowserWindow(0).CommandBar.TabBand;
var
tabs = tabPanel.FindAll(
"ObjectType"
,
"TabButton"
);
tabs = (
new
VBArray(tabs)).toArray();
tabs[TabIndex - 1].Click();
}