Is there a way to wait for the WPF Application to open

2 Answers 329 Views
Test Configuration Test Execution
Terry
Top achievements
Rank 1
Iron
Terry asked on 05 Apr 2022, 09:00 PM

I am testing a WPF application that needs to open after services are started.  I have written another application that starts the services and then the WPF application (application under test) and I used this launcher as my startup application.  The problem is, that my tests fail because the WPF MainWindow window is yet available.  Does this WPF MainWindow need to be a child of the startup application?  Is there a way to make the test application wait for the MainWindow to launch?   

The reason why I am doing it this way, is that I need to restart the services and application after each test, and not just the wpf test.  Any suggestions?

 

 

2 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 06 Apr 2022, 10:59 AM

Hi Terry,

This is somewhat common scenario, although for different reasons, but I think you will find this approach suitable for you. As the test starts, Test Studio will launch the application that is configured for that WPF test. If you need to connect the execution to another WPF application, you can use the suggestion in this article. The example shows how to connect to a running application based on the process name, but you can use other process properties.

Once the test is done, Test Studio will close the application it was connected to. I would like to point out that you need to ensure that the application is in the expected state, before it is closed. This might affect the state of the application when it is started again next time.

Let me know if the suggestion does not cover your scenario and share more details. I will be happy to continue our discussion and assist you.

Regards,
Plamen Mitrev
Progress Telerik

Does UI testing really fit into CI/CD?

If you want to find out how to take advantage of continuous delivery pipelines, join our Test Studio webinar on Wednesday, April 6 at 11 am EST | 5 pm CET.

0
Emma
Top achievements
Rank 1
Iron
answered on 19 May 2022, 09:05 PM
If your launch application is triggering application 2 and all you need to do is wait for the window, then you might be interested in 
ActiveApplication.WaitForWindow(string caption, int timeout);
Alternatively, if you have elements from the application window saved in your element explorer, you could try a Wait for Exists on one of them.
Tags
Test Configuration Test Execution
Asked by
Terry
Top achievements
Rank 1
Iron
Answers by
Plamen Mitrev
Telerik team
Emma
Top achievements
Rank 1
Iron
Share this question
or