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

Value/Text of a selected item from RadComboBox

2 Answers 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 03 Jul 2012, 02:27 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 03 Jul 2012, 04:19 PM
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
0
Joe
Top achievements
Rank 1
answered on 03 Jul 2012, 05:19 PM
Thanks a lot, I got it working now
Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Joe
Top achievements
Rank 1
Share this question
or