Forum Discussion

Oleksandr13's avatar
Oleksandr13
New Contributor
9 years ago
Solved

TestComplete does not recognize Office Ribbon elements

We use Office Ribbon (http://officeribbon.codeplex.com/) and TestComplete does not recognize ribbon elements. Object Inspector recognizes ribbon as single element without childs. It recognizes it name and class, but cannot recognize all items as single components.

obj.png

 

 

Do I need to change some settings or add some plugins to TestComplete?

 

Can TestComplete recognize these elements at all?

 

 

WPFRibbon controls are set.

ribbon.jpg

 

 

Thanks

  • Hi Oleksandr,

    There's no built-in recording & playback support for the WinForms Office Ribbon control, but you can automate it by using its internal properties and methods - those in the .NET category in the Object Browser.

    For example, you can access the ribbon items as:

    ribbonObj.Tabs.Item(index).Panels(index).Items(index)

    and its Quick Toolbar items as:

    ribbonObj.QuickAccessToolbar.Items.Item(index)


    From there you can get and change the item state. Examine these objects in the Object Browser to learn which properties and methods you can use for various item types.

    For example, to click a button you can use something like this:

    // JScript
    // Click the 1st button in the 1st tab
    var item = ribbonObj.Tabs.Item(0).Panels(0).Items(0);
    var bounds = item.Bounds;
    ribbon.Click(bounds.Left + bounds.Width/2, bounds.Top + bounds.Height/2);

     

    Hope this helps!


    You can also submit a feature request for adding built-in support for Office Ribbon:
    http://support.smartbear.com/testcomplete-survey
    http://community.smartbear.com/t5/TestComplete-Feature-Requests/idb-p/TestXCompleteFeatureRequests

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Oleksandr,

    There's no built-in recording & playback support for the WinForms Office Ribbon control, but you can automate it by using its internal properties and methods - those in the .NET category in the Object Browser.

    For example, you can access the ribbon items as:

    ribbonObj.Tabs.Item(index).Panels(index).Items(index)

    and its Quick Toolbar items as:

    ribbonObj.QuickAccessToolbar.Items.Item(index)


    From there you can get and change the item state. Examine these objects in the Object Browser to learn which properties and methods you can use for various item types.

    For example, to click a button you can use something like this:

    // JScript
    // Click the 1st button in the 1st tab
    var item = ribbonObj.Tabs.Item(0).Panels(0).Items(0);
    var bounds = item.Bounds;
    ribbon.Click(bounds.Left + bounds.Width/2, bounds.Top + bounds.Height/2);

     

    Hope this helps!


    You can also submit a feature request for adding built-in support for Office Ribbon:
    http://support.smartbear.com/testcomplete-survey
    http://community.smartbear.com/t5/TestComplete-Feature-Requests/idb-p/TestXCompleteFeatureRequests

    • Oleksandr13's avatar
      Oleksandr13
      New Contributor

      Thanks for telling me about the workaround. 

      I will try.