Forum Discussion

MadsNygaard's avatar
MadsNygaard
Occasional Contributor
14 years ago

Process.Exists logs unwanted error

As a part of my keyword tests, I'm checking the existance of a certain process ('process'.Exists), before I do some steps. My problem is, that I get an error in the log, if the process doesn't exist, which polutes my log, as it isn't an error to me. I just want a False result without an error.

Is there any way I can circumvene TC logging this as an error?



BR

Mads Nygaard

  • karkadil's avatar
    karkadil
    Valued Contributor
    This solution should work for you.



    function Test1()

    {

      if(Sys.WaitProcess("calcplus", 0).Exists)

      {

        Log.Message("Process exists, terminating...");

        Sys.Process("calcplus").Terminate();

      }

      TestedApps.CalcPlus.Run();

     

    }
  • MadsNygaard's avatar
    MadsNygaard
    Occasional Contributor
    I forgot to mention, that the logged error is "Process not found", which shouldn't really be nessesary when you're trying to determine if the process exists.
  • karkadil's avatar
    karkadil
    Valued Contributor
    Simply use



    Sys.WaitProcess(...).Exists



    instead of



    Sys.Process(...).Exists



    The same suggestion for waiting windows (WaitWindow/WaitWinFormsObject/etc.).



    Usage examples can be easily found in the Help.
  • MadsNygaard's avatar
    MadsNygaard
    Occasional Contributor
    Ah, I should have been more clear about what I want to do.



    Ideally, the process shouldn't exist, but if it exists, I need to terminate it, before going on with the test. So I can't  really use WaitProcess as that would also ultimately result in an error, if the process doesn't exits.