cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to click on ribbon items

Contributor

Not able to click on ribbon items

We need to automate test scripts that runs multiple environemnts like US, German etc.So I am trying to write a script to click on Devx ribbon items that works in all locals.I found one commaon property called "Name" and I am looping through ribbon items to get a name and trying to click on that.

1.I tried Perform click but test execute not able to proceed further after perform click so daily execution is getting struck.

2.I tried 

var RibbonItem=RibbonControl.Items.Item(i);
RibbonItem.Click();

But there is no click method for RibbonItem.

3.There is click item mothod for RibbonControl but it takes either index or text.

if I try RibbonControl.clickitem() I am not able click on items of item.

 

Is there any other I can click Ribbon item here?

If I record then this how it is generating code

RibbonControl.ClickItem("Print Preview|Document|Save")

 

code:

function clickRibbobControl(RibbonControl,Name)
{

// Get the tool bar and item key and click on the item
var itemsListCount = RibbonControl.Items.Count;
var tempKeyValue;
//Loops throgh items and gets the position and clicks on it
for(var i=0;i<itemsListCount;i++)
{
tempKeyValue=RibbonControl.Items.Item(i).Name;
if(tempKeyValue == Name)
{
Log["Message"](i);
//Below PerformClick Action makes TC to get stuck after the click action
//RibbonControl["Items"]["Item"](i)["PerformClick"]();
var RibbonItem=RibbonControl.Items.Item(i);
RibbonItem.Click();

break;
}
}
return 0;
}

3 REPLIES 3
Community Leader

Re: Not able to click on ribbon items

Check whether RibbonItem is an Object/Variable.

 

I'm not really clear on the problem. but try using descriptive programming.

 

Use FindAllChildren to find the objects that display on the list of Object based on the property. Try to print the Name.

 

then use FindChild using the Name property and other few properties to click on the Element. 

 

If this doesn't help try to use Visible or VisibleOnScreen property which may try to identify the property and Click.

 

 

With Regards
Vallalarasu Pandiyan | LinkedIn |Vallalarasu.p@gmail.com
Community Hero

Re: Not able to click on ribbon items

Item will not have a "Click" method because it is a data item, not an on screen component.  So, TestComplete will not "wrap" a Click method on it.

You've already discovered that ClickItem is the means to click on the desired option.  Because they run similar to a menu, each sub-option in the menu is separated by a verticle pipe.  So, in your example from recording, TestComplete will click on Print Preview followed by Document followed by Save.  This is how you click on items in a ribbon control.

 

So... to solve your problem, what you need to do is pass in the item as the full path for the location (US, German, etc).

 

code would be, simply

RibbonControl.ClickItem(Name)

You would just pass in the following

 

US : Name = 'Print Preview|Document|Save'

German: Name = 'Druckvorschau|Dokumentieren|sparen'

 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Not able to click on ribbon items

I was too facing the same problem for long .finally i resolved using click grid function

where I can click using Grid name, Coloum name and finally the cell value name where i want to click.

i am searching the cell value name in the specified colomn and performing ClickCell('cell no','coloum name','viewid default 0')

let me if.it helps or else i can post you the full function
New Here?
Join us and watch the welcome video: