How to Find Elements in Wpf Application?

10 posts, 0 answers
  1. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 20 May 2013 Link to this post

    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


  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 21 May 2013 Link to this post

    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
  3. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 21 May 2013 Link to this post

    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
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 21 May 2013 Link to this post

    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
  5. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 22 May 2013 Link to this post

    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
  6. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 24 May 2013 Link to this post

    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
  7. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 27 May 2013 Link to this post

    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

      
  8. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 28 May 2013 Link to this post

    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
  9. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 03 Jun 2013 Link to this post

    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

     
  10. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 03 Jun 2013 Link to this post

    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
Back to Top