Forum Discussion

zelvin's avatar
zelvin
New Contributor
13 years ago

Fail to click on menu item

Fail to click on menu item

Hi all,

   Recently my scripts have some troubles to click on the menu item in our application. It happens randomly and it can be fail to open any menu items each time the scripts run. It leaves the mouse pointer stay at the menu item without click on it. No any error message occur other than left the ‘#32768’ pop-up stay opened with the message ‘The menu item ‘File|[0]’ was clicked’ in the log file.

We have tried to create a simple application (MenuTestApp) with the exact menu item in our main application (Phoenix6). Running the scripts work fine in this simple application but not in our main application. Not sure what causing it and why it happen.  If anyone got any idea please let me know. Below is a simple script that I created to test this two applications.  Please note that, I am using TestComplete 9 testing on window 7 and window XP machines.



function openMenu1(menuItem) : OleVarient;

var

  p1, w1 : OleVarient;

begin

  result := TRUE;

  case method of

    1 : begin

          p1 := Sys.Process('MenuTestApp'); 

          w1 := p1.VCLObject('Form1').MainMenu;

        end;

    2 : begin

          p1 := Sys.Process('Phoenix6'); 

          w1 := p1.VCLObject('FrmCropsMain').MainMenu;

        end;

   

  end;

   

  case menuItem of

    1 : w1.Click('File|[0]');

    2 : w1.Click('File|[2]');

    3 : w1.Click('File|[3]');

    4 : w1.Click('File|[5]');            

  end;

end;

 

 

function openMenu2(menuItem) : OleVarient;

var

  p1, w1 : OleVarient;

begin

  result := TRUE;

  case method of

    1 : begin

          p1 := Sys.Process('MenuTestApp'); 

          w1 := p1.VCLObject('Form1').MainMenu;

        end;

    2 : begin

          p1 := Sys.Process('Phoenix6'); 

          w1 := p1.VCLObject('FrmCropsMain').MainMenu;

        end;

   

  end;

 

  case menuItem of

    1 : w1.Click('Setup|[0]');

    2 : w1.Click('Setup|[1]');

    3 : w1.Click('Setup|[2]');

    4 : w1.Click('Setup|[3]');   

    5 : w1.Click('Setup|[4]');

    6 : w1.Click('Setup|[5]');

    7 : w1.Click('Setup|[6]');

    8 : w1.Click('Setup|[7]');

    9 : w1.Click('Setup|[8]');

    10: w1.Click('Setup|[9]');

    11: w1.Click('Setup|[10]');    

    12: w1.Click('Setup|[11]');

    13: w1.Click('Setup|[13]');

    14: w1.Click('Setup|[14]');

  end;

 

end;

 

function openMenu3(menuItem) : OleVarient;

var

  p1, w1 : OleVarient;

begin

  result := TRUE;

  case method of

    1 : begin

          p1 := Sys.Process('MenuTestApp'); 

          w1 := p1.VCLObject('Form1').MainMenu;

        end;

    2 : begin

          p1 := Sys.Process('Phoenix6'); 

          w1 := p1.VCLObject('FrmCropsMain').MainMenu;

        end;

   

  end;

 

  case menuItem of

    1 : w1.Click('Tasks|[0]');

    2 : w1.Click('Tasks|[1]');

    3 : w1.Click('Tasks|[3]');    

  end;

 

end;

 

 

function openMenu4(menuItem) : OleVarient;

var

  p1, w1 : OleVarient;

begin

  result := TRUE;

  case method of

    1 : begin

          p1 := Sys.Process('MenuTestApp'); 

          w1 := p1.VCLObject('Form1').MainMenu;

        end;

    2 : begin

          p1 := Sys.Process('Phoenix6'); 

          w1 := p1.VCLObject('FrmCropsMain').MainMenu;

        end;

   

  end;

  case menuItem of

    1 : w1.Click('Tools|[0]');    

  end;

 

end;

 

function openMenu5(menuItem) : OleVarient;

var

  p1, w1 : OleVarient;

begin

  result := TRUE;

  case method of

    1 : begin

          p1 := Sys.Process('MenuTestApp'); 

          w1 := p1.VCLObject('Form1').MainMenu;

        end;

    2 : begin

          p1 := Sys.Process('Phoenix6'); 

          w1 := p1.VCLObject('FrmCropsMain').MainMenu;

        end;

   

  end;

 

  case menuItem of

    1 : w1.Click('Help|[0]');

    2 : w1.Click('Help|[2]');

    3 : w1.Click('Help|[4]');

    4 : w1.Click('Help|[5]');   

    5 : w1.Click('Help|[7]');    

  end;

 

end;

 

procedure main;

var i, p1, menuNo, itemNo, maxMenuItem, result   : OleVariant;

begin

  for method := 1 to 2 do

  begin

    for menuNo := 1 to 5 do

    begin

      case menuNo of

        1 : maxMenuItem := 4;

        2 : maxMenuItem := 14;

        3 : maxMenuItem := 3;

        4 : maxMenuItem := 1;

        5 : maxMenuItem := 5;

      end;

      for itemNo := 1 to maxMenuItem do

      begin  

        case menuNo of

          1 : result := openMenu1(itemNo);

          2 : result := openMenu2(itemNo);

          3 : result := openMenu3(itemNo);

          4 : result := openMenu4(itemNo);

          5 : result := openMenu5(itemNo);

        end;

        case method of

          1 : Sys.Process('MenuTestApp').Window('#32770', 'Menutestapp').Window('DirectUIHWND').Window('CtrlNotifySink', '', 7).Window('Button', 'OK').ClickButton;

          2 : Sys.Process('Phoenix6').Window('#32770', 'Phoenix v6').Window('DirectUIHWND').Window('CtrlNotifySink', '', 7).Window('Button', 'OK').ClickButton;         

        end;           

      end;

    end;

  end;

end;

  • zelvin's avatar
    zelvin
    New Contributor
    We have found out that the problem is related to the TChromium component. Once this component is created we experience problems with menus being unable to be clicked from within TestComplete 9. We do not experience any problems when manually using the menus.



    Has anyone else had this issue or have any ideas how to proceed?

  • Hi Zelvin,


     


    As far as I know, you are working with David from our Support team on this issue. When you have results, please post them here.