Closing application window

2 Answers 110 Views
WPF Testing
Dawid
Top achievements
Rank 1
Iron
Dawid asked on 28 Jul 2021, 01:56 PM

Hi, 

I'm wondering if there is a possibility to close a window using X button in the window header during test execution. 

The problem that I'm facing is that sometimes I need to close a sub window in test but when I click "X" button Test Studio doesn't record that step.  I was also unable to find a solution to this problem using code behind. 

Thanks, 

Dawid

2 Answers, 1 is accepted

Sort by
0
Accepted
Plamen Mitrev
Telerik team
answered on 29 Jul 2021, 11:51 AM

Hello Dawid,

I assume that you are automating WPF application and you want to close one of the windows with the X button. By default, Test Studio will not record the window state changes - minimize, maximize, restore and close. You can enable the recording option responsible for this automation scenario and record the necessary steps in your WPF test.

Another option is to use a coded step to close the last window in the WPF application, based on the order they appeared. The sample code below does not apply for dialogs.

System.Threading.Thread.Sleep(2000);
ActiveApplication.Windows.LastOrDefault().Window.Close();

Please correct me if the above assumption is not true and share more details and screenshots from the application under test and your test scenario. Thank you!

Regards,
Plamen Mitrev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
0
Dawid
Top achievements
Rank 1
Iron
answered on 29 Jul 2021, 12:27 PM

Thanks. This solves my problem.  

Best Regards,
Dawid 

Tags
WPF Testing
Asked by
Dawid
Top achievements
Rank 1
Iron
Answers by
Plamen Mitrev
Telerik team
Dawid
Top achievements
Rank 1
Iron
Share this question
or