how to get return value out of tested application put into testcomplete project variable
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2010
06:03 PM
04-22-2010
06:03 PM
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!
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2010
10:43 PM
04-22-2010
10:43 PM
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. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2010
02:55 AM
04-23-2010
02:55 AM
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
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2010
03:15 AM
04-26-2010
03:15 AM
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. ⬇️⬇️⬇️
