Forum Discussion
AlexeyKolosov
14 years agoStaff
Hello,
As you know, the MainMenu.Click method requires the path to a menu item as a parameter. The path can be built based either on menu item captions, or on menu item indices. It's possible to obtain necessary indices/captions for a menu item by using the native TMenuItem.Parent method.
The following helper routine illustrates how to form a valid path for a menu item:
function GetPathByMenuItem(item){
var index = "[" + item.MenuIndex + "]";
var path = index;
while( item.NativeDelphiObject != null && item.NativeDelphiObject.Parent != null){
item = item.NativeDelphiObject.Parent;
path = "[" + item.MenuIndex + "]|" + path;
}
return path;
}
//usage
var mainMenu = Sys.Process("Orders").VCLObject("MainForm").MainMenu;
var item = Sys.Process("Orders").VCLObject("MainForm").VCLObject("File_New")
mainMenu.Click(GetPathByMenuItem(item));
So, your script will be language-independent, but will use TestComplete's MainMenu.Click method to perform clicks visually.
Does this work for you?
Related Content
Recent Discussions
- 26 minutes agodhundley