Value/Text of a selected item from RadComboBox

3 posts, 1 answers
  1. Joe
    Joe avatar
    2 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2012 Link to this post

    Hello,

    Working on the UI Testing, I'm wondering how would I get text/value from a already selected RadComboBox.
    Thanks for reading - Joe

    [TestMethod]
    public void SampleWebAiiTest()
    {
        Settings.Current.Web.EnableSilverlight = true;
        Manager.LaunchNewBrowser();
        ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#ComboBox/FirstLook");
        SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
     
        Telerik.WebAii.Controls.Xaml.RadComboBox cb = app.Find.ByAutomationId<Telerik.WebAii.Controls.Xaml.RadComboBox>("TechnologySelection");
        Assert.IsNotNull(cb);
        cb.SelectItem("Silverlight", true);
        Assert.AreEqual("Silverlight", cb.Text); // Not working, Expected <Silverlight>, Actual <>
     
        System.Threading.Thread.Sleep(1000);
    }
  2. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 03 Jul 2012 Link to this post

    Hello Joe,

    You'll need to explicitly refresh the ComboBox after making the selection to update the Text property:

    cb.SelectItem("Silverlight", true);
    System.Threading.Thread.Sleep(1000);
     
    cb.Refresh();
    Assert.AreEqual("Silverlight", cb.Text);


    Greetings,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Joe
    Joe avatar
    2 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2012 Link to this post

    Thanks a lot, I got it working now
Back to Top