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

Example to access and test WPF/MVVM applications using the Webaii Testing framework

8 Answers 287 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Souvika
Top achievements
Rank 1
Souvika asked on 12 Jun 2011, 10:50 PM
Hi,

Can you please provide us with a code sample to connect to a wpf executable (windows app) using the latest webaii testing framework and some samples of how to find by name of xaml objects and write text on a textbox and invoke button ASAP please.

We are already using the framework for our web applications therefore we were wondering if the same can be extended for WPF apps, etc..

Thanks.

Kind Regards,
Souvika

8 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 15 Jun 2011, 03:31 PM
Hi Souvika,
    the documentation on WPF testing with the Framework is still under construction. I added an article explaining a basic example, check it out here:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/telerik-testing-framework/wpf-test-automation.aspx
You can expect more content to appear in the upcoming days.

Greetings,
Stoich
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Souvika
Top achievements
Rank 1
answered on 15 Jun 2011, 11:42 PM
Hi Stoich,

Thanks for your reply. Everything is working fine for now - I need to test combobox, etc and then let you know. Thanks again.
 

 

 

 

Cheers,
Souvika



 

 

0
Souvika
Top achievements
Rank 1
answered on 20 Jun 2011, 05:43 AM
Hi Stoich,

Can you please provide me with an example of selecting an item from combo box in an wpf application?

I am trying the following:

ComboBox

 

 

cb = new ComboBox();

 

cb = app.MainWindow.Find.ByName<

 

ComboBox>("optionsComboBox");

 

cb.SelectItemByText(

 

false, "RightAlign");

 

It is failing at "SelectItemByText"

Cheers,
Souvika

0
Stoich
Telerik team
answered on 20 Jun 2011, 01:05 PM
Hi Souvika,
   you seem to be missing the necessary logic to open the dropbox. Here's what the correct code should look like:
ComboBox cb = new ComboBox();
cb = app.MainWindow.Find.ByName<ComboBox>("optionsComboBox");
cb.OpenDropDown(false);
cb.SelectItemByText(false, "RightAlign");

All the best,
Stoich
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
John
Top achievements
Rank 1
answered on 19 Aug 2011, 12:18 PM
That link is broken - it should be:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/telerik-testing-framework/silverlight-test-automation/wpf-test-automation.aspx

But the sample doesn't work with version 2011.1.712.0. It should be more like:

using ArtOfTest.WebAii.Controls.Xaml.Wpf;
using ArtOfTest.WebAii.TestTemplates;
using ArtOfTest.WebAii.Wpf;
using NUnit.Framework;
 
namespace Tester
{
    [TestFixture]
    public class TestClass : BaseTest
    {
        private WpfApplication wpfApp;
 
        [SetUp]
        public void TestClassSetup()
        {
            // Launch the application instance from its location in file system
            this.Initialize();
            wpfApp = Manager.LaunchNewApplication(@"C:\MyProjects\WPFWebAiiTest\WPFWebAiiTest\bin\Debug\WPFWebAiiTest.exe");
        }
 
        [Test]
        public void ClickButtonTest()
        {
 
   // Validate the title of the main window
              Assert.IsTrue(wpfApp.MainWindow.Window.Caption.Equals("MainWindow"));
   
   //Get the button
              Button b =   wpfApp.MainWindow.Find.ByName<Button>("button1");
   
   //Click the button 
              b.User.Click();
   
   //Get the text box
             TextBox tb = wpfApp.MainWindow.Find.ByName<TextBox>("textBlock1");
   
   //Verify the text
             Assert.IsTrue(tb.Text.Equals("Yo!"));
        }
    }
}


************IMPORTANT NOTE!!!!!!*****************
The test project (as with all webaii test projects) MUST be targetted to x86, and *not* x64 or Any CPU.
FYI I'm using NUnit.

0
Stoich
Telerik team
answered on 22 Aug 2011, 03:49 PM
Hi John,
    thank you for the feedback.

I apologize for the broken link. We recently introduced some changes to the documentation which necessitated changes in the URLs for some sections. I've requested that a redirect be implemented for this link so that it won't appear to be broken.

You're also right about the article on WPF. I've added the following disclaimer:
The template for this method is based on a VsUnit test. However, the code itself can be reused in other type of Unit tests - it's just the template that will be different.

Thank you for providing working code for the Nunit format - it will be useful to other users.

Best wishes,
Stoich
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
Dennis
Top achievements
Rank 1
answered on 11 Aug 2014, 07:36 PM
Can you please provide the correct links to the documentation concerning WPF testing? Both links referenced in this thread are broken. Thank you.
0
Boyan Boev
Telerik team
answered on 14 Aug 2014, 11:46 AM
Hi Dennis,

Please excuse us for the broken link.

Here is the correct link: http://docs.telerik.com/teststudio/user-guide/write-tests-in-code/silverlight-test-automation/wpf-test-automation.aspx

If you need further assistance, please let us know.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Souvika
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Souvika
Top achievements
Rank 1
John
Top achievements
Rank 1
Dennis
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or