Forum Discussion

bravemen's avatar
bravemen
New Contributor
7 years ago

how to verify my program was uninstalled successfully

this is my first post to this community, please let me know if more information is needed.

 

i am trying to determine whether a program has been uninstalled successfully from Windows 8.1.  below is the method i have attempted:

 

 

// the alias here is the Add/Remove Program in Windows

var my_program = Aliases.explorer.wndCabinetWClass.ShellTabWindowClass.

                             DUIViewWndClassName.DirectUIHWND.CtrlNotifySink.ShellView.FolderView.wItem("XT 300", 0);

Log.Message( "my program name is " + my_program);  // shows "XT 300", my application

 

// during my test, i would uninstall the program at this point.  but to test my logic, i keep the XT 300 

// program installed.  i would like to see the error below happen but it never does

 

if( Aliases.explorer.wndCabinetWClass.ShellTabWindowClass.DUIViewWndClassName.

                       DirectUIHWND.CtrlNotifySink.ShellView.FindChild( "wItem(\"XT 300\", 0)", "XT 300" ).Exists ) {

            Log.Error( "XT 300 application is still installed after running Uninstall" );  // why am i not seeing this?

} else {

// continue

}

 

i have tried finding information on the web, thinking that this must be a common thing to do, but i haven't found anything.  if there is a better way to test that my program is uninstalled correctly, please let me know.  but i would still like to know why i'm having such a difficult time with the wItem property.  i believe it has to do with the fact that the property takes parameters.  i have tested my code with other properties (that do not take parameters) of the Add/Remove Program and they work with no issue (for instance, wColumnCount worked with no problem).  so there is something i am missing in trying to pass a property that has parameters to the FindChild method (i've tried other Findxxx methods and they don't work either).  

 

any help will be greatly appreciated!

  • so, i figured out a different way to test this.  instead of looking for a child object, i decided to look directly at the objects properties.  interestingly, saw this in the Remarks section of WaitProperty method: 

     

    "The WaitProperty method does not support indexed properties (that is, properties that require parameters). "

     

    so there must be something unusual with having indexed properties.  so right after that line, they give an example of a while loop to use instead of the WaitProperty.  so i did that (with a for loop) and got what i needed.  here is the new code:

     

    var XT300_uninstalled = false;

    var folderViewObj = Aliases.explorer.wndCabinetWClass.ShellTabWindowClass.DUIViewWndClassName.DirectUIHWND.CtrlNotifySink.ShellView.FolderView;
    // waitproperty method doesn't support indexed properties like the wItem on the folderview object. so need
    // to check the property using for loop. wait up to 5 seconds for XT 300 application to be uninstalled
    for( var i=0; i<5; i++ ) {
        if( aqString.Compare( folderViewObj.wItem(2, 0), "XT 300", true ) != 0 ) {
             XT300_uninstalled = true;
             break;
        } else {
             Delay( 1000 );
             folderViewObj.Refresh();
        }

    }

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    If I got your question right, then this is expected and as per the documentation for the FindChild() method:

    -- You did not specify third parameter (Depth), thus FindChild() searched only within immediate children;

    -- wItem() is a child of ShellView.FolderView but not of ShellView, thus FindChild() failed, .Exists evaluated to false and Log.Error() was not posted.

     

    P.S.

    > FindChild( "wItem(\"XT 300\", 0)", "XT 300" )

    Check in the Object Browser if the property named wItem("XT 300", 0) has indeed the "XT 300" value.

     

    • bravemen's avatar
      bravemen
      New Contributor

      hi alex,

       

      thank you for the response.  i did add the depth value just now, and it still did not work.  please correct me if i'm wrong, but here is my thought process for this.  i am looking for an object, ShellView.FolderView, which has a property, wItem(2, 0), that is equal to "XT 300".  therefore, the FindChild method is looking for children of the ShellView.FolderView's parent, ie, ShellView.  so the FindChild method should be called from ShellView, not ShellView.FolderView.

       

      if there is a better way than what i'm doing to determine this, please let me know as i'm fairly new to TestComplete...thanks!

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > if there is a better way than what

        The answer depends on what do you actually need.

        E.g. :

        If you need to check that before uninstall the entry is present in the list and is absent there after uninstall, then what you do is probably the best way. (Note, this does not guarantee either that the application was actually uninstalled/unregistered in the system, nor that all its files and folders were removed.)

        If you need to check that after uninstall all files and folders are removed, then you may consider uninstall from the command line with subsequent verification that files/folders were removed.

         

  • bravemen's avatar
    bravemen
    New Contributor

    so, i figured out a different way to test this.  instead of looking for a child object, i decided to look directly at the objects properties.  interestingly, saw this in the Remarks section of WaitProperty method: 

     

    "The WaitProperty method does not support indexed properties (that is, properties that require parameters). "

     

    so there must be something unusual with having indexed properties.  so right after that line, they give an example of a while loop to use instead of the WaitProperty.  so i did that (with a for loop) and got what i needed.  here is the new code:

     

    var XT300_uninstalled = false;

    var folderViewObj = Aliases.explorer.wndCabinetWClass.ShellTabWindowClass.DUIViewWndClassName.DirectUIHWND.CtrlNotifySink.ShellView.FolderView;
    // waitproperty method doesn't support indexed properties like the wItem on the folderview object. so need
    // to check the property using for loop. wait up to 5 seconds for XT 300 application to be uninstalled
    for( var i=0; i<5; i++ ) {
        if( aqString.Compare( folderViewObj.wItem(2, 0), "XT 300", true ) != 0 ) {
             XT300_uninstalled = true;
             break;
        } else {
             Delay( 1000 );
             folderViewObj.Refresh();
        }

    }