This is a migrated thread and some comments may be shown as answers.

RoutedEventArgs not generated by User.Click

3 Answers 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maylad
Top achievements
Rank 1
Maylad asked on 03 Jan 2019, 09:42 PM

Hello,

Recently I have started using Testing Framework to test WPF applications (MVVM). Maybe it's the novice's problem but i can't generate RoutedEventArgs on my_button.User.Click(); Operations like TypeText() or Click() should be treated like a normal user actions, aren't they?

 

I am trying something like this:

 _wpfWindow.Find.ByName(UI_Components.Button_LogIn).User.Click();

or

 _wpfWindow.Find.ByName(UI_Components.TextBox_Name).User.TypeText(login, 1, 5, true);

 

During click on LogIn Button (by real mouse)  is activating method, by Click() option not. The same problem I have with generating events for KeyPress:

private void OnKeyDownPressed(object sender, KeyEventArgs e)
{
          if (e.Key == Key.Enter)
                  runXXX();
}

private void OnLoginButtonClick(object sender, RoutedEventArgs e)
{
           runXXX();
}

How can i fix it or generate KeyEventArgs or RoutedEventArgs. Btw. I couldn't change the code from this both methods, necessary condition.

Greetings.

3 Answers, 1 is accepted

Sort by
0
Nikolai
Telerik team
answered on 08 Jan 2019, 11:37 AM
Hello Michal,

Thank you for the detailed description provided. 

The behavior you have faced, may occur sometimes against heavier apps or slower machines. The testing framework extension needs to configure the app in order to trigger the proper event chain.

A small wait on the test side after the application launches, should fix the issue: 

this.Manager.LaunchNewApplication(@"C:\Temp\DemoWpfApp.exe");
System.Threading.Thread.Sleep(5000);

I'm attaching a DemoWpfApp , which you can use to run the below simple test against:

this.Manager.LaunchNewApplication(@"C:\Temp\DemoWpfApp.exe");
System.Threading.Thread.Sleep(5000);           
 
var button = this.ActiveApplication.MainWindow.Find.ByName<Button>("MyButton");           
button.User.Click();

If the "Click()" is successful all the routed events should be triggered:
 1. "PreviewMouseDown"
 2. "PreviewMouseUp"
 3. "Click"

Please give a try to the proposed solution and let me know if any further assistance will be necessary. 

Thank you in advance for your cooperation. 

Regards,
Nikolai
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Maylad
Top achievements
Rank 1
answered on 14 Jan 2019, 08:44 AM
Thank you for the answer, I will try and then I let you know
0
Nikolai
Telerik team
answered on 16 Jan 2019, 04:15 PM
Hi Maylad,

Take your time and if the issue persist please let us know. Additionally, we use Test Studio to automate most of our internal web and desktop apps, so if our internal testers find something similar I'll let you know as well.

Regards,
Nikolai
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Maylad
Top achievements
Rank 1
Answers by
Nikolai
Telerik team
Maylad
Top achievements
Rank 1
Share this question
or