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

How to Find Elements in Wpf Application?

9 Answers 745 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sudarshan
Top achievements
Rank 2
Sudarshan asked on 21 May 2013, 04:31 AM
Hi,

How to find elements in a wpf application?

I referred to the link below:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/silverlight-test-automation/wpf-test-automation.aspx

I don't have the source code of the application or the element Properties, how can i find the elements in the application?

I was able to launch the application from visual studio using the coded step.

WpfApplication wpf = Manager.LaunchNewApplication(@"Application.APPREF-MS");

Application is launching but i'm not able to Find the elements In it.

Attached below the screenshot from Telerik Website.
How to Get the element Properties in the application? 

Thanks
Sudarshan


9 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 May 2013, 08:04 AM
Hello Sudarshan,

In order to determine the correct way to find the elements in your WPF application, you need a special tool that will allow you to see the Visual Tree of you application. For example, you can use this WPF Snoop utility:
http://snoopwpf.codeplex.com/releases/view/73187

Once you are able to see the WPF Visual Tree and the attributes of the elements, you can start automating your app. Everything is explained in our Silverlight/WPF Automation section. For example, you can access your WPF elements as seen in this article and perform actions on them as seen here.
 
If you're having difficulty, please provide a sample WPF application(in a zip file) and explain what exactly you want to automate, so I can provide you with a code sample based on your automation scenario. 

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 21 May 2013, 02:18 PM
Hi plamen,

Thanks for the response. 

I downloaded the Snoop tool and now i'm able to find the element properties.

can you send me demonstration of automating any wpf app? 

Thanks
Sudarshan
0
Plamen
Telerik team
answered on 21 May 2013, 03:27 PM
Hello Sudarshan,

I am glad to hear you are making progress. We have a sample WPF automation demo available here, along with an explanation of each line of code. This should be enough to get you started. If you're having difficulty with a specific scenario, please provide us with more detailed information on what exactly is your automation challenge so we can assist you effectively.

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 22 May 2013, 02:25 PM
Hi Plamen,

I referred to the link u sent.
I'm not able to proceed. i'm getting some errors.

1. WpfApplication wpfApp = Manager.LaunchNewApplication(@"path");
2. Assert.IsTrue(wpfApp.MainWindow.Window.Caption.Equals("MainWindow"));
3. wpfApp.MainWindow.Find.ByName<Button>("Buttonname").User.Click();


When i tried to run the code build failed and the error was in the second line saying "object should be referenced"

I then removed the second line and ran the code, build succeeded, but test failed and the error was in this line "
wpfApp.MainWindow.Find.ByName<Button>("Buttonname").User.Click();"
saying object reference not set to the instance of the object..

I'm able to launch the application but not able to automate it.
The element properties i'm using in the test are correct but i'm getting these errors. What changes should i make?

Thanks
Sudarshan
0
Plamen
Telerik team
answered on 24 May 2013, 10:43 AM
Hi Sudarshan,

I was able to reproduce the issue and it turned out that there is a bug with the latest version of our Framework. You can track its progress here: Public URL.

The workaround is to manually drag and drop the Newtonsoft.Json.dll from the Test Studio's Bin folder to GAC(Global Assembly Cache). See this video for a quick demonstration.

I have also updated your Telerik points for discovering the issue.

Please excuse us for the caused inconvenience.

Regards,
Plamen
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 28 May 2013, 03:33 AM
Hi Plamen,

Thanks for the Response.

I don't find the Newtonsoft.Json.dll in the Bin Folder.

I'm using Telerik testing framework 2011.1.

Thanks
Sudarshan

  
0
Plamen
Telerik team
answered on 28 May 2013, 07:36 AM
Hi Sudarshan,

Please try to upgrade to our latest internal build 2012.2.1527. It contains a lot of bug fixes and improvements related to WPF testing. You can download it from your Telerik account here: Public URL. After the upgrade you should be able to see the Newtonsoft.Json.dll in the Test Studio's Bin folder. Add it to the GAC and let me know if the issue persists.

Regards,
Plamen
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Sudarshan
Top achievements
Rank 2
answered on 03 Jun 2013, 07:17 AM
Hi Plamen,

I downloaded the latest build 2012.2.1527 and installed it on my machine.

I have added the Newtonsoft.Json.dll to the GAC.

Application is launching fine but i'm not able to proceed further and automate the application.

I'm getting a different error this time "System.InvalidOperationException: Process has exited, so the requested information is not available"
 
Attaching the screenshots (Error Message, Coding scrrenshot, Application properties, GAC).

The application extension is .appref-ms
 
Thanks
Sudarshan

 
0
Plamen
Telerik team
answered on 03 Jun 2013, 04:08 PM
Hi Sudarshan,

Unfortunately I'm still not able to reproduce the problem. One thing I noticed however is that you're using ReSharper which comes with a test runner that may conflict with the MsTest runner used by Visual Studio to execute and debug the test. Please try disabling or uninstalling ReSharper. The ReSharper test runner is untested by Telerik and can cause different problems, like this one for example.

If you continue to have difficulty, please send us a sample WPF application(in a zip file) that you have problems with, so we can investigate and find the root cause of the issue.

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