Forum Discussion
KB1
2 years agoChampion Level 2
Yes, I'm not an c# expert with testcomplete but I think this will work. if not please dm me we can investigate this further
using System;
using TestCompleteIntegrationNamespace; // Replace with the actual namespace of your TestCompleteIntegration library
public class TestCompleteIntegrationObject
{
private ITestCompleteCOMManager TestCompleteManager;
private ItcIntegration IntegrationObject;
private object TestCompleteObject;
private const string TCProgID = "TestComplete.TestCompleteApplication.14";
public TestCompleteIntegrationObject()
{
this.InitializeTcObject();
if (IntegrationObject != null)
{
// Subscribe to integration events
IntegrationObject.OnLogMessage += IntegrationObject_OnLogMessage;
IntegrationObject.OnWarningMessage += IntegrationObject_OnWarningMessage;
IntegrationObject.OnError += IntegrationObject_OnError;
IntegrationObject.OnInfoMessage += IntegrationObject_OnInfoMessage;
}
}
public void InitializeTcObject()
{
try
{
TestCompleteObject = Marshal.GetActiveObject(TCProgID);
}
catch
{
try
{
TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Unable to initialize TestComplete.");
}
}
if (TestCompleteObject != null)
{
TestCompleteManager = (ITestCompleteCOMManager)TestCompleteObject;
IntegrationObject = TestCompleteManager.Integration;
}
}
private void IntegrationObject_OnLogMessage(string message)
{
// Handle log message here
// You can collect and format the messages as needed
}
private void IntegrationObject_OnWarningMessage(string message)
{
// Handle warning message here
}
private void IntegrationObject_OnError(string message)
{
// Handle error message here
}
private void IntegrationObject_OnInfoMessage(string message)
{
// Handle info message here
}
}
Related Content
- 13 years ago
- 4 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago