Forum Discussion

Actinomorphic's avatar
Actinomorphic
Occasional Contributor
6 years ago

Script vs Keyword Test with Delphi menu items

This script works fine for checking the expected enabled/disabled state of submenu items.

 

function Connect_No_Loggers_Check_Menus()
{
var Process, Window, MainMenu, Submenu, Item;
Process = Sys.Process("ConnectScreen");
Window = Process.FormMain;
MainMenu = Window.MainMenu;
Submenu = MainMenu.Items("File").Submenu;
Item = Submenu.Items("Select Server...");
aqObject.CheckProperty(Item,"Enabled",0,true);
Item = Submenu.Items("Connect");
aqObject.CheckProperty(Item,"Enabled",0,false);
Item = Submenu.Items("Disconnect");
aqObject.CheckProperty(Item,"Enabled",0,false);
Item = Submenu.Items("Exit");
aqObject.CheckProperty(Item,"Enabled",0,true);
}

 

I'd like to do the same in a Keyword Test. The problem is that this is a Delphi application, and using the object browser, I cannot drill down all the way to the submenu items. The deepest I can go is to TMenuItem (the submenus).

 

Sys.Process("ConnectScreen").VCLObject("FormMain").VCLObject("MainMenu").VCLObject("TMenuItem")

 

I'm still wrapping my head around what I can do in scripts vs. keyword tests. How can I specify the submenu by name or index and submenu item by name or index that I want to examine in a keyword test?

 

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    There are, quite honestly, limtiations in keyword tests.  Basically, you can do the same, but I find it cumbersome in keyword tests to build out similar code.

    However.... since you have the script code, you CAN call that from a keyword test.  There is an operation in keyword tests to run a script routine.  It doesn't make any sense to re-invent the wheel... just call your script from your keyword test... in fact, I find this the BETTER way to do things in a team that doesn't have a lot of coding experience... those who can code help write utility functions like this and those who can't code so well incorporate those into the keyword tests.  Everyone is happy then. :-)