Problem with ComboBox in WPF

2 posts, 0 answers
  1. Ali
    Ali avatar
    1 posts
    Member since:
    Jun 2011

    Posted 10 Jun 2011 Link to this post

    I have a small test using Test Framework. Here's the sample code:

    public void TestTextBox()
        WpfApplication wpfApp = Manager.LaunchNewApplication(@"C:\Projects\myapp.exe");
        var loginWindow = wpfApp.GetWindow("Login");
        loginWindow.Find.ByName<TextBox>("usernameTextBox").Text = "user1";
        loginWindow.Find.ByName<PasswordBox>("passwordTextBox").Password = "pass1";
        loginWindow.Find.ByName<ComboBox>("environmentComboBox").SelectItemByText(false, "DEV");
        loginWindow.Find.ByName<Button>("connectButton").Click(MouseClickType.LeftClick, false, false, 0, 0, OffsetReference.AbsoluteCenter, ActionPointUnitType.Pixel);

    On following line:
    I get the following error:

    System.InvalidCastException : Unable to cast object of type 'ArtOfTest.WebAii.Wpf.WpfWindow' to type 'ArtOfTest.WebAii.Silverlight.SilverlightApp'.
       at ArtOfTest.WebAii.Silverlight.UI.ComboBox.get_Items()
       at ArtOfTest.WebAii.Silverlight.UI.ComboBox.RefreshItemsForSelection()
       at ArtOfTest.WebAii.Silverlight.UI.ComboBox.SelectItemByText(Boolean simulateRealUser, String text)
       at TelerikTestFramework.TelerikNUnitTest1.TestTextBox() in TelerikNUnitTest1.cs: line 135

    What may be the problem?

    The other question is about the maturity of Telerik Testing Framework for WPF. I only see two classes in Wpf namespace and all controls are returned from Silverlight namespace. Even though the framework looks great and clean, but I'm reluctant to recommend Telerik's framework if it's not prepared to test WPF apps.

  2. Stoich
    Stoich avatar
    1 posts

    Posted 17 Jun 2011 Link to this post

    Hello Ali,
         the problem is that you're trying to use the WebAii Silverlight API instead of the WPF API. I'm not sure how ti happend - my guess is that you created a TelerikTestingFramework web test (screenshot 1) and then you added the WPF extension with a "using" statement. Try creating a new test item but make sure it's a Wpf test.

    Let me know if you're still unable to resove this.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top