Cannot select RadListBoxItem

4 posts, 0 answers
  1. Cheryl
    Cheryl avatar
    45 posts
    Member since:
    Jul 2006

    Posted 15 Aug 2011 Link to this post

    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

  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 17 Aug 2011 Link to this post

    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!
  3. Eric
    Eric avatar
    1 posts
    Member since:
    Apr 2012

    Posted 22 May 2012 Link to this post

    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.
  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 23 May 2012 Link to this post

    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
Back to Top