Ask a Question

how to get return value out of tested application put into testcomplete project variable

pgrow
New Contributor

how to get return value out of tested application put into testcomplete project variable

I have an c# application which does some work (separate from any script) and I need to get the result out of it back into my testcomplete script any way possible, so far I have tried the 'Creating Connected Applications in C#', I am able to start the c#.exe from my unit script below, but I don't know how to get the string result of the application. So far I am trying the method where testecomplete has the dll in its project CLR bridge, so I thought it has access to the object of my C# application, and its result-right? Or is there another way? I checked the help, and wish I had seen there was an example for this.

My project looks like this:

LoadSuite

 LoadProject

  Unit1

function Main()

{

  try

  {

      var p;

      p = TestedApps["Items"](0)["Run"](); //this is Authentication.Authprogram C# program



      //HOW TO GET STRING RESULT from the app I just started? p.?



      while (p["Exists"])

        aqUtils["Delay"](500);

 

  }

  catch(exception)

  {

    Log["Error"]("Exception", exception["description"]);

  }

}



my C# app:

namespace Authentication

{

    public class AuthProgram

    {



     public static string HttpPost(string uri, string parameters)

        {  

           string foo;

         //etc, etc, does some stuff -tested it, this function works!

          returns foo;

   }



I followed the help carefully , included the testcomplete 2 dll's in the C# application assembly and got the app's dll put and recognized into testcomplete project properties, etc.Thanks for any advice!
3 REPLIES 3

Hi Paule,


As I understand, you need to read your application's output from the standard output stream. If so, I recommend that you see the "Testing Console Applications" ( http://www.automatedqa.com/support/viewarticle.aspx?aid=6744 ) help topic - it contains the sample script you need.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
pgrow
New Contributor

I am trying your suggestion but TC cannot find my process. 'Process not found. The object does not exist'.

Can anyone help..

I added the console app to my TestedApps.

Here is new script - it appears I only needed to modify the 3rd line for my app name.



Sub MyTest

  Dim p, w, txt, cnt, i, s



  Set p = Sys.Process("ConsoleAuth.exe")

  Set w = p.Window("ConsoleWindowClass", "*")



  txt = w.wText

  ' Specify the separator

  aqString.ListSeparator = vbNewLine

  ' Obtain the list's length

  cnt = aqString.GetListLength(txt)



  For i = 0 To cnt - 1

    ' Obtain a line

    s = aqString.GetListItem(txt, i)

    ' Post the line to the test log

    Call Log.Message(s)

  Next

End Sub

Hi Paule,


You do not need to include the ".exe" string in the process name. Just use the name as it is specified in the Object Browser window.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: