Forum Discussion

john_van_arkele's avatar
john_van_arkele
New Contributor
11 years ago

Testing Windows start menu

Hi, I am trying to test the Windows start menu. Things like open the start menu, check the number of application items in the start menu, count the number of shortcuts on the desktop, etc.



Is this at all possible with TestComplete? When I record something, it ignores the start menu actions and adds a "Run TestedApp" action instead.



Thanks,

JOhn

  • Hi John,



    Here's a couple of ideas:



    count the number of shortcuts on the desktop


    Try this:

    Sys.Process("explorer").Window("Progman").Window("SHELLDLL_DefView").Window("SysListView32").wItemCount


    check the number of application items in the start menu


    Start Menu shortcuts are stored in these folders on the disk:

    Common to all users: %ALLUSERSPROFILE%\Start Menu\Programs

    User-specific: %USERPROFILE%\Start Menu\Programs



    You could simply count the shortcut files in the needed subfolder. Something like this (off top of my head):



    function Test()

    {

      Log.Message(GetStartMenuItemCount("SmartBear\\TestComplete 10"));

    }



    // Returns the number of shortcuts in the specified Start Menu folder.

    // Path - String. The folder path in the Start Menu, separated by backslashes.

    // For example, "SmartBear\\TestComplete 10".

    function GetStartMenuItemCount(Path)

    {

      var oShell = Sys.OleObject("Wscript.Shell");

      var strStartMenuCommon = oShell.SpecialFolders("AllUsersPrograms"); // common Start Menu

      var strStartMenuUser = oShell.SpecialFolders("Programs"); // user-specific Start Menu



      var strPath1 = aqFileSystem.IncludeTrailingBackSlash(strStartMenuCommon) + Path;

      var strPath2 = aqFileSystem.IncludeTrailingBackSlash(strStartMenuUser) + Path;



      var count = 0;



      if (aqFileSystem.Exists(strPath1))

      {

        count += aqFileSystem.GetFolderInfo(strPath1).Files.Count;

      }



      if (aqFileSystem.Exists(strPath2))

      {

        count += aqFileSystem.GetFolderInfo(strPath2).Files.Count;

      }



      return count;

    }


  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)


    Hi John,



    Here's a couple of ideas:



    count the number of shortcuts on the desktop


    Try this:

    Sys.Process("explorer").Window("Progman").Window("SHELLDLL_DefView").Window("SysListView32").wItemCount


    check the number of application items in the start menu


    Start Menu shortcuts are stored in these folders on the disk:

    Common to all users: %ALLUSERSPROFILE%\Start Menu\Programs

    User-specific: %USERPROFILE%\Start Menu\Programs



    You could simply count the shortcut files in the needed subfolder. Something like this (off top of my head):



    function Test()

    {

      Log.Message(GetStartMenuItemCount("SmartBear\\TestComplete 10"));

    }



    // Returns the number of shortcuts in the specified Start Menu folder.

    // Path - String. The folder path in the Start Menu, separated by backslashes.

    // For example, "SmartBear\\TestComplete 10".

    function GetStartMenuItemCount(Path)

    {

      var oShell = Sys.OleObject("Wscript.Shell");

      var strStartMenuCommon = oShell.SpecialFolders("AllUsersPrograms"); // common Start Menu

      var strStartMenuUser = oShell.SpecialFolders("Programs"); // user-specific Start Menu



      var strPath1 = aqFileSystem.IncludeTrailingBackSlash(strStartMenuCommon) + Path;

      var strPath2 = aqFileSystem.IncludeTrailingBackSlash(strStartMenuUser) + Path;



      var count = 0;



      if (aqFileSystem.Exists(strPath1))

      {

        count += aqFileSystem.GetFolderInfo(strPath1).Files.Count;

      }



      if (aqFileSystem.Exists(strPath2))

      {

        count += aqFileSystem.GetFolderInfo(strPath2).Files.Count;

      }



      return count;

    }