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

Cannot select RadListBoxItem

3 Answers 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 16 Aug 2011, 03:21 AM

I have a test where I'm first verifying that a button is enabled, then I click that button and it changes to a RadListBox.
I can verify that a particular item = index 1 or whatever, but I can't seem to click an item to select.

On Record, the step is added to the test:

RadListBoxItem('ctl00_ContentPlaceHolder1_lstMyTeam_i1'): '
Australia' action -> 'Select'

but on running the test it fails at this line with

'16/08/2011 2:23:46 p.m.' - 'Fail' : 7. RadListBoxItem('ctl00_ContentPlaceHolder1_lstMyTeam_i1'): 'Australia' action -> 'Select'------------------------------------------------------------Failure Information: ~~~~~~~~~~~~~~~Object reference not set to an instance of an object.InnerException:System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.WebAii.Controls.Html.RadListBoxItem.Select() at Telerik.WebAii.Design.Translators.Html.ListBox.RadListBoxItemActionDescriptor.Execute(Browser browser) at ArtOfTest.WebAii.Design.Extensibility.HtmlActionDescriptor.Execute(IAutomationHost autoHost) at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep(Int32 order)

Is there anything that I need to check or any setting i need to change in order to be able to select an item in a RadListBox?

Thanks

3 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 17 Aug 2011, 12:45 PM
Hi Cheryl,

See below an example which works at our side:

[TestMethod]
       public void MoveUp()
       {
           Manager.LaunchNewBrowser();
 
           RadListBox listBox = Find.ById<RadListBox>("RadListBox1");
           Assert.AreEqual("Amelie", listBox.Items[1].Text);
 
           listBox.Items[1].Select();
           Assert.AreEqual(true, listBox.Items[1].Selected);
 
           listBox.MoveUp();
           Wait.For<RadListBox>(myListBox => myListBox.Items[0].Text == "Amelie", listBox, 5000);
       }

Does it work at your side?
Could you please send us a sample .aspx page which contains your RadListBox declaration or a live url to examine the problem locally?

Regards,
Helen
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
Eric
Top achievements
Rank 1
answered on 22 May 2012, 08:34 PM
hi Helen

I'm looking for a way to select and radlistbox item by text in a webform?

So far I have:

            var userListBox = CurrentManager.ActiveBrowser.Find.ById<RadListBox>("~lstUsers");
            var TestViewerItem = userListBox.FindItems(x => x.Text=="test.viewer").First();
            TestViewerItem.Wait.ForExists(5000);
            TestViewerItem.Select();



The problem is it keeps hanging at line 2, var TestViewerItem.
0
Anthony
Telerik team
answered on 23 May 2012, 06:44 PM
Hello Eric,

Are you certain there's an item in your ListBox where the text matches "test.viewer"? I adapted Helen's code to include your sample and it worked as long as I used matching text for one of the list items.

If you continue to have difficulty, please provide a public site that I can run your code against directly and see the issue first-hand.

Greetings,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Cheryl
Top achievements
Rank 1
Answers by
Helen
Telerik team
Eric
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or