Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 20073

How to check if a specific Item on a MenuItem object exist

$
0
0

I'm handling a MenuItem object, but this menu work with permissions filters and sometimes the option i need to interact isn't present on screen. 

 

To check if that option exist before send the action to the object, i access the Item in the position expected to be my option by the index and get the Caption property value. If that Caption matches with the option i expect, i send the action (click, selection, ...).

 

I'm looking in the SmartBear Community and Support for other ways, but not succesfully. Anyone can help?

 

C#:

 

//Items(4): Position i expect my option, if the user has permission to see it.

 

var expectedOptionName = "optionX";

var optionText = Menu["PopupMenu"].Items(4).Caption;

if(optionText == expectedOptionName)
{
    Menu["PopupMenu"]["Click"](4);
}
else
{
    Log["Message"]("Option is disabled for this user.");
}


Viewing all articles
Browse latest Browse all 20073

Trending Articles