Forum Discussion

TimCalderwood's avatar
TimCalderwood
New Contributor
5 years ago

ClickTab with Icons

Our JavaFX application uses tabs with icons in the tab title. Looking at Object browser, the tabs have two labels, the first label is "" and the sub label has the tab text. So, when we try to use ClickTab, with the text, ClickTab fails. Using an index is not an option because there is no guarantee of what of the tab order is at any given time. I have not figured out a way to find the tab index correctly using the tab title. 

 

Therefore, what is the best way to select tabs when tabs use icons and text in the tab title? Attached is a screenshot of object viewer. 

  • BenoitB's avatar
    BenoitB
    5 years ago

    A last solution would be to use image search of icons for tabs (assuming each tab has its own icon).

    So add in image store your icons and search them in the parent object picture. After that you'll have coordinates where to click.

     

    That is not perfect but it could work.

    • TimCalderwood's avatar
      TimCalderwood
      New Contributor

      I agree with FindChild and have used id usefully to get the sub label of the label. However, I have not been able to determine the index number of the tab that it is associated with it. Is there is a function of way to determine the index number of tab that contains the object returned by FindChild. 

      • BenoitB's avatar
        BenoitB
        Community Hero

        When spying look at the tab Method/functions instead of Properties tab, perhaps you can find an useful method

  • BenoitB's avatar
    BenoitB
    Community Hero

    You can access tab with browser model by page title perhaps (works only if page title change with tab)  ?

     

    // Iexplorer/old Edge
    let tabBand = browser.BrowserWindow(0).CommandBar.TabBand;
    // Chrome/Firefox
    let tabBand = browser.UIPage("chrome://browser/content/browser.xul").TabBand;
    
    tabBand.TabButton(page.contentDocument.title).Click();