Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:30:41+00:00 2026-05-30T00:30:41+00:00

I have a simple wpf app which has a button that increments a value

  • 0

I have a simple wpf app which has a button that increments a value on clicking. I also have a function that returns the latest value. The default value is 5. I also have a UI test in testcomplete that clicks the button 3 times (so 8). I need to call the .Net function to get this value and assert it. Below is my test code.

After some search I figured out the CLRbridge details and implemented it. However, As you can see below, the UI test instance and the instance on which I am claling the function are different. So, the function returns 5.

My question is, how do I invoke the function from the same instance loaded by testcomplete. Or am I going completely the wrong way for this? I tried both script and UI test with if..then, nothing worked. I have tried both direct instance and calling on the appdomain, both doesnt seem to work.

NOTE: I do understand that I can display the value in a UI control and validate the control. However, i am specifically trying this out for a more complex testing functionality we need in a project.

function Test2()
{
  var Increment;
  Increment = 0;
  //Runs the "TCompTest" tested application.
  TestedApps.TCompTest.Run();
  //Clicks the 'button1' button.
  Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
  //Clicks the 'button1' button.
  Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
  //Clicks the 'button1' button.
  Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
  //Increment = dotNET.Incrementer.Incr1.zctor().IntValue(true);

Increment = dotNET.Incrementer.Incr1.zctor().IntValue(true);

**OR**

 Increment = Sys.Process("TCompTest").AppDomain("TCompTest.exe").dotNET.Incrementer.Incr1.zctor().IntValue(true)

 // if(Increment == 8)
 // {//Posts an information message to the test log.
  Log.Message(Increment);
//  }
  //Closes the 'HwndSource_MainWindow' window.
  Aliases.TCompTest.HwndSource_MainWindow.Close();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:30:43+00:00Added an answer on May 30, 2026 at 12:30 am

    It should be possible to do what you need from TestComplete. But first of all, to avoid misunderstanding, let me explain the problems with the approaches you tried:

    1. Addressing a class through the “dotNET” object.
      When you do this, TestComplete initializes .NET in its service process, loads the specified assembly into it, and works with the classes of this assembly loaded to TestComplete’s AppDomain (though living in a separate process). This means that this instance of your assembly has nothing to do with your tested application. So, you can’t access your application’s data through the dotNET object.

    2. Addressing the Incrementer assembly through the tested application’s AppDomain.
      OK, in this case you are closer to a solution – you work with the AppDomain of the tested application, so you can access the application’s data. However, in your code, you create a new instance of the Incr1 class (via calling zctor). This means that the new class instance will initialize its counter in the constructor, and it will be 5. And this is the value you are getting in your code.

    So, the right approach:

    Unless the counter field of the Incr1 class containing the current counter value is a static field, you need to address an existing object of the Incr1 class to get the current value of the property, not to create a new class instance. The actual implementation will depend on where you are storing the Incr1 class instance reference in your application. Let’s suppose, you store the reference in the Counter property of the MainWindow object:

    // Creating an instance of the class somewhere in your code
    MainWindow.Counter = new Incr1();
    
    // ...    
    
    // And this line of code is in the button click handler
    MainWindow.Counter.Increment();
    

    In the described case, you will be able to get the current counter value in your TestComplete script as follows:

      var MainWnd = Aliases.TCompTest.HwndSource_MainWindow.MainWindow;
      Log.Message(MainWnd.Counter.IntValue(true));
    

    If your setup is different, please describe it – I will try to help accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WPF (XAML) file that has some animated shapes and text.
I am totally new to WPF, I have created a simple WPF app that
In my WPF app I have a data import function which imports data from
I have an app which runs fine as a simple WPF app having an
I have a simple WPF application which I am trying to start. I am
I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a very simple WPF application in which I am using data binding
I have a simple message box in a WPF application that is launched as
I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX
I have a WPF application that mostly follows MVVM, which I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.