Automated WPF Testing with Telerik Test Studio

Software testing helps to make sure that the software does what it’s supposed to do which improve the software quality. It’s also a validation process that identify any bugs or  missing requirements.

Sometimes software testing can fall behind due to a number of reasons,  low test case coverage or less effort in manual testing  when checking if the software works fine after a code modification or a bug fix. Here is where Automated Testing can come to rescue.

My team  has chosen Telerik Test Studio as test automation tool to increase test coverage and to convert some manual tests into automated scripts. By creating a suite of automated tests, we can basically create tests that run just like a QA person might manually run.  Because these executing scripts are automated tests, we can run them at the end of every sprint or periodically after each build to check that nothing that was working before is now broken.

Test Studio is very user friendly test automation tool. It has many feature like UI recording, specialized verification and other test functionalities that require no programming. But that being said, some tasks can be very tricky to solve.

I encountered a problem while writing an automated WPF Test:

The WPF-App started from a ClickOnce shortcut and i couldn’t get the Test Studio UI-Recorder to be attached to it. I posted this issue to Telerik Test Studio Forum and to Stackoverflow. Sadly, I didn’t get any working solution.

After spending two days on this task,  I came to a solution that I wanted to share in this post. Here are the steps:

1. First of all I created a dummy WPF App (DummyApp.exe)  to feed Test Studio because you cannot run a  WPF Test unless you provide a definite path for the app you want to test.

I copied the dummy  app in a definite location:

%USERPROFILE%\AppData\Roaming

2.  I started Telerik Test Studio and I created a project with the name UI-Tests. I setted the default path for the real WPF App under Project -> Settings, as shown below:

AutomatedTestStep1

3. I created a WPF-Test named Initialization. Under Configure, I setted the WPF Application Path to the dummy application path, as shown below:

AutomatedTestStep2

4. I added a Coded Step to the test. In this Coded step, I defined the logic that will shut down the dummy app, then start and connect to the current version of the real app.

AutomatedTestStep3

Here’s the code:

5. After running the Initialization-Test, I created another WPF-Test that launch the real app and records the steps needed.

6. Finally I created a Test List and I added the two tests to it, as shown below:

AutomatedTestStep4

This Test List run the Initialization-Test first that run and copied the current version of the real app into the specified folder: “C\Workspace“. The second test will execute the steps recorded on it.

I hope that this solution will be helpful to someone and will save a much valuable time.

 

Leave a Reply

2 Comments

  1. Anupma

    Thanks for the solution…

Next Article7 Ways To Overcome Procrastination